brainllm 10.5.2 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -20,12 +20,14 @@ var __toESM = (mod, isNodeMode, target) => {
20
20
  }
21
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
22
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
- for (let key of __getOwnPropNames(mod))
24
- if (!__hasOwnProp.call(to, key))
25
- __defProp(to, key, {
26
- get: __accessProp.bind(mod, key),
27
- enumerable: true
28
- });
23
+ if (mod && typeof mod === "object" || typeof mod === "function") {
24
+ for (let key of __getOwnPropNames(mod))
25
+ if (!__hasOwnProp.call(to, key))
26
+ __defProp(to, key, {
27
+ get: __accessProp.bind(mod, key),
28
+ enumerable: true
29
+ });
30
+ }
29
31
  if (canCache)
30
32
  cache.set(mod, to);
31
33
  return to;
@@ -46,7 +48,7 @@ var __export = (target, all) => {
46
48
  };
47
49
 
48
50
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/codegen/code.js
49
- var require_code = __commonJS((exports) => {
51
+ var require_code = __commonJS(function(exports) {
50
52
  Object.defineProperty(exports, "__esModule", { value: true });
51
53
  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 = undefined;
52
54
 
@@ -200,7 +202,7 @@ var require_code = __commonJS((exports) => {
200
202
  });
201
203
 
202
204
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/codegen/scope.js
203
- var require_scope = __commonJS((exports) => {
205
+ var require_scope = __commonJS(function(exports) {
204
206
  Object.defineProperty(exports, "__esModule", { value: true });
205
207
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = undefined;
206
208
  var code_1 = require_code();
@@ -346,7 +348,7 @@ var require_scope = __commonJS((exports) => {
346
348
  });
347
349
 
348
350
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/codegen/index.js
349
- var require_codegen = __commonJS((exports) => {
351
+ var require_codegen = __commonJS(function(exports) {
350
352
  Object.defineProperty(exports, "__esModule", { value: true });
351
353
  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._ = undefined;
352
354
  var code_1 = require_code();
@@ -1056,7 +1058,7 @@ var require_codegen = __commonJS((exports) => {
1056
1058
  });
1057
1059
 
1058
1060
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/util.js
1059
- var require_util = __commonJS((exports) => {
1061
+ var require_util = __commonJS(function(exports) {
1060
1062
  Object.defineProperty(exports, "__esModule", { value: true });
1061
1063
  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 = undefined;
1062
1064
  var codegen_1 = require_codegen();
@@ -1220,7 +1222,7 @@ var require_util = __commonJS((exports) => {
1220
1222
  });
1221
1223
 
1222
1224
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/names.js
1223
- var require_names = __commonJS((exports) => {
1225
+ var require_names = __commonJS(function(exports) {
1224
1226
  Object.defineProperty(exports, "__esModule", { value: true });
1225
1227
  var codegen_1 = require_codegen();
1226
1228
  var names = {
@@ -1245,7 +1247,7 @@ var require_names = __commonJS((exports) => {
1245
1247
  });
1246
1248
 
1247
1249
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/errors.js
1248
- var require_errors = __commonJS((exports) => {
1250
+ var require_errors = __commonJS(function(exports) {
1249
1251
  Object.defineProperty(exports, "__esModule", { value: true });
1250
1252
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = undefined;
1251
1253
  var codegen_1 = require_codegen();
@@ -1363,7 +1365,7 @@ var require_errors = __commonJS((exports) => {
1363
1365
  });
1364
1366
 
1365
1367
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/boolSchema.js
1366
- var require_boolSchema = __commonJS((exports) => {
1368
+ var require_boolSchema = __commonJS(function(exports) {
1367
1369
  Object.defineProperty(exports, "__esModule", { value: true });
1368
1370
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = undefined;
1369
1371
  var errors_1 = require_errors();
@@ -1411,7 +1413,7 @@ var require_boolSchema = __commonJS((exports) => {
1411
1413
  });
1412
1414
 
1413
1415
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/rules.js
1414
- var require_rules = __commonJS((exports) => {
1416
+ var require_rules = __commonJS(function(exports) {
1415
1417
  Object.defineProperty(exports, "__esModule", { value: true });
1416
1418
  exports.getRules = exports.isJSONType = undefined;
1417
1419
  var _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"];
@@ -1439,7 +1441,7 @@ var require_rules = __commonJS((exports) => {
1439
1441
  });
1440
1442
 
1441
1443
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/applicability.js
1442
- var require_applicability = __commonJS((exports) => {
1444
+ var require_applicability = __commonJS(function(exports) {
1443
1445
  Object.defineProperty(exports, "__esModule", { value: true });
1444
1446
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = undefined;
1445
1447
  function schemaHasRulesForType({ schema, self }, type) {
@@ -1459,7 +1461,7 @@ var require_applicability = __commonJS((exports) => {
1459
1461
  });
1460
1462
 
1461
1463
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/dataType.js
1462
- var require_dataType = __commonJS((exports) => {
1464
+ var require_dataType = __commonJS(function(exports) {
1463
1465
  Object.defineProperty(exports, "__esModule", { value: true });
1464
1466
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = undefined;
1465
1467
  var rules_1 = require_rules();
@@ -1640,7 +1642,7 @@ var require_dataType = __commonJS((exports) => {
1640
1642
  });
1641
1643
 
1642
1644
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/defaults.js
1643
- var require_defaults = __commonJS((exports) => {
1645
+ var require_defaults = __commonJS(function(exports) {
1644
1646
  Object.defineProperty(exports, "__esModule", { value: true });
1645
1647
  exports.assignDefaults = undefined;
1646
1648
  var codegen_1 = require_codegen();
@@ -1674,7 +1676,7 @@ var require_defaults = __commonJS((exports) => {
1674
1676
  });
1675
1677
 
1676
1678
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/code.js
1677
- var require_code2 = __commonJS((exports) => {
1679
+ var require_code2 = __commonJS(function(exports) {
1678
1680
  Object.defineProperty(exports, "__esModule", { value: true });
1679
1681
  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 = undefined;
1680
1682
  var codegen_1 = require_codegen();
@@ -1803,7 +1805,7 @@ var require_code2 = __commonJS((exports) => {
1803
1805
  });
1804
1806
 
1805
1807
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/keyword.js
1806
- var require_keyword = __commonJS((exports) => {
1808
+ var require_keyword = __commonJS(function(exports) {
1807
1809
  Object.defineProperty(exports, "__esModule", { value: true });
1808
1810
  exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = undefined;
1809
1811
  var codegen_1 = require_codegen();
@@ -1918,7 +1920,7 @@ var require_keyword = __commonJS((exports) => {
1918
1920
  });
1919
1921
 
1920
1922
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/subschema.js
1921
- var require_subschema = __commonJS((exports) => {
1923
+ var require_subschema = __commonJS(function(exports) {
1922
1924
  Object.defineProperty(exports, "__esModule", { value: true });
1923
1925
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = undefined;
1924
1926
  var codegen_1 = require_codegen();
@@ -1998,7 +2000,7 @@ var require_subschema = __commonJS((exports) => {
1998
2000
  });
1999
2001
 
2000
2002
  // node_modules/fast-deep-equal/index.js
2001
- var require_fast_deep_equal = __commonJS((exports, module) => {
2003
+ var require_fast_deep_equal = __commonJS(function(exports, module) {
2002
2004
  module.exports = function equal(a, b) {
2003
2005
  if (a === b)
2004
2006
  return true;
@@ -2040,7 +2042,7 @@ var require_fast_deep_equal = __commonJS((exports, module) => {
2040
2042
  });
2041
2043
 
2042
2044
  // node_modules/json-schema-traverse/index.js
2043
- var require_json_schema_traverse = __commonJS((exports, module) => {
2045
+ var require_json_schema_traverse = __commonJS(function(exports, module) {
2044
2046
  var traverse = module.exports = function(schema, opts, cb) {
2045
2047
  if (typeof opts == "function") {
2046
2048
  cb = opts;
@@ -2123,7 +2125,7 @@ var require_json_schema_traverse = __commonJS((exports, module) => {
2123
2125
  });
2124
2126
 
2125
2127
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/resolve.js
2126
- var require_resolve = __commonJS((exports) => {
2128
+ var require_resolve = __commonJS(function(exports) {
2127
2129
  Object.defineProperty(exports, "__esModule", { value: true });
2128
2130
  exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = undefined;
2129
2131
  var util_1 = require_util();
@@ -2276,7 +2278,7 @@ var require_resolve = __commonJS((exports) => {
2276
2278
  });
2277
2279
 
2278
2280
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/index.js
2279
- var require_validate = __commonJS((exports) => {
2281
+ var require_validate = __commonJS(function(exports) {
2280
2282
  Object.defineProperty(exports, "__esModule", { value: true });
2281
2283
  exports.getData = exports.KeywordCxt = exports.validateFunctionCode = undefined;
2282
2284
  var boolSchema_1 = require_boolSchema();
@@ -2781,7 +2783,7 @@ var require_validate = __commonJS((exports) => {
2781
2783
  });
2782
2784
 
2783
2785
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/validation_error.js
2784
- var require_validation_error = __commonJS((exports) => {
2786
+ var require_validation_error = __commonJS(function(exports) {
2785
2787
  Object.defineProperty(exports, "__esModule", { value: true });
2786
2788
 
2787
2789
  class ValidationError extends Error {
@@ -2795,7 +2797,7 @@ var require_validation_error = __commonJS((exports) => {
2795
2797
  });
2796
2798
 
2797
2799
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/ref_error.js
2798
- var require_ref_error = __commonJS((exports) => {
2800
+ var require_ref_error = __commonJS(function(exports) {
2799
2801
  Object.defineProperty(exports, "__esModule", { value: true });
2800
2802
  var resolve_1 = require_resolve();
2801
2803
 
@@ -2810,7 +2812,7 @@ var require_ref_error = __commonJS((exports) => {
2810
2812
  });
2811
2813
 
2812
2814
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/index.js
2813
- var require_compile = __commonJS((exports) => {
2815
+ var require_compile = __commonJS(function(exports) {
2814
2816
  Object.defineProperty(exports, "__esModule", { value: true });
2815
2817
  exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = undefined;
2816
2818
  var codegen_1 = require_codegen();
@@ -3031,7 +3033,7 @@ var require_compile = __commonJS((exports) => {
3031
3033
  });
3032
3034
 
3033
3035
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/refs/data.json
3034
- var require_data = __commonJS((exports, module) => {
3036
+ var require_data = __commonJS(function(exports, module) {
3035
3037
  module.exports = {
3036
3038
  $id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
3037
3039
  description: "Meta-schema for $data reference (JSON AnySchema extension proposal)",
@@ -3048,7 +3050,7 @@ var require_data = __commonJS((exports, module) => {
3048
3050
  });
3049
3051
 
3050
3052
  // node_modules/fast-uri/lib/utils.js
3051
- var require_utils = __commonJS((exports, module) => {
3053
+ var require_utils = __commonJS(function(exports, module) {
3052
3054
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3053
3055
  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);
3054
3056
  function stringArrayToHexStripped(input) {
@@ -3303,7 +3305,7 @@ var require_utils = __commonJS((exports, module) => {
3303
3305
  });
3304
3306
 
3305
3307
  // node_modules/fast-uri/lib/schemes.js
3306
- var require_schemes = __commonJS((exports, module) => {
3308
+ var require_schemes = __commonJS(function(exports, module) {
3307
3309
  var { isUUID } = require_utils();
3308
3310
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3309
3311
  var supportedSchemeNames = [
@@ -3477,7 +3479,7 @@ var require_schemes = __commonJS((exports, module) => {
3477
3479
  });
3478
3480
 
3479
3481
  // node_modules/fast-uri/index.js
3480
- var require_fast_uri = __commonJS((exports, module) => {
3482
+ var require_fast_uri = __commonJS(function(exports, module) {
3481
3483
  var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
3482
3484
  var { SCHEMES, getSchemeHandler } = require_schemes();
3483
3485
  function normalize(uri, options) {
@@ -3728,7 +3730,7 @@ var require_fast_uri = __commonJS((exports, module) => {
3728
3730
  });
3729
3731
 
3730
3732
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/uri.js
3731
- var require_uri = __commonJS((exports) => {
3733
+ var require_uri = __commonJS(function(exports) {
3732
3734
  Object.defineProperty(exports, "__esModule", { value: true });
3733
3735
  var uri = require_fast_uri();
3734
3736
  uri.code = 'require("ajv/dist/runtime/uri").default';
@@ -3736,7 +3738,7 @@ var require_uri = __commonJS((exports) => {
3736
3738
  });
3737
3739
 
3738
3740
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/core.js
3739
- var require_core = __commonJS((exports) => {
3741
+ var require_core = __commonJS(function(exports) {
3740
3742
  Object.defineProperty(exports, "__esModule", { value: true });
3741
3743
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = undefined;
3742
3744
  var validate_1 = require_validate();
@@ -4329,7 +4331,7 @@ var require_core = __commonJS((exports) => {
4329
4331
  });
4330
4332
 
4331
4333
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/core/id.js
4332
- var require_id = __commonJS((exports) => {
4334
+ var require_id = __commonJS(function(exports) {
4333
4335
  Object.defineProperty(exports, "__esModule", { value: true });
4334
4336
  var def = {
4335
4337
  keyword: "id",
@@ -4341,7 +4343,7 @@ var require_id = __commonJS((exports) => {
4341
4343
  });
4342
4344
 
4343
4345
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/core/ref.js
4344
- var require_ref = __commonJS((exports) => {
4346
+ var require_ref = __commonJS(function(exports) {
4345
4347
  Object.defineProperty(exports, "__esModule", { value: true });
4346
4348
  exports.callRef = exports.getValidate = undefined;
4347
4349
  var ref_error_1 = require_ref_error();
@@ -4460,7 +4462,7 @@ var require_ref = __commonJS((exports) => {
4460
4462
  });
4461
4463
 
4462
4464
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/core/index.js
4463
- var require_core2 = __commonJS((exports) => {
4465
+ var require_core2 = __commonJS(function(exports) {
4464
4466
  Object.defineProperty(exports, "__esModule", { value: true });
4465
4467
  var id_1 = require_id();
4466
4468
  var ref_1 = require_ref();
@@ -4478,7 +4480,7 @@ var require_core2 = __commonJS((exports) => {
4478
4480
  });
4479
4481
 
4480
4482
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
4481
- var require_limitNumber = __commonJS((exports) => {
4483
+ var require_limitNumber = __commonJS(function(exports) {
4482
4484
  Object.defineProperty(exports, "__esModule", { value: true });
4483
4485
  var codegen_1 = require_codegen();
4484
4486
  var ops = codegen_1.operators;
@@ -4507,7 +4509,7 @@ var require_limitNumber = __commonJS((exports) => {
4507
4509
  });
4508
4510
 
4509
4511
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
4510
- var require_multipleOf = __commonJS((exports) => {
4512
+ var require_multipleOf = __commonJS(function(exports) {
4511
4513
  Object.defineProperty(exports, "__esModule", { value: true });
4512
4514
  var codegen_1 = require_codegen();
4513
4515
  var error2 = {
@@ -4532,7 +4534,7 @@ var require_multipleOf = __commonJS((exports) => {
4532
4534
  });
4533
4535
 
4534
4536
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/ucs2length.js
4535
- var require_ucs2length = __commonJS((exports) => {
4537
+ var require_ucs2length = __commonJS(function(exports) {
4536
4538
  Object.defineProperty(exports, "__esModule", { value: true });
4537
4539
  function ucs2length(str) {
4538
4540
  const len = str.length;
@@ -4555,7 +4557,7 @@ var require_ucs2length = __commonJS((exports) => {
4555
4557
  });
4556
4558
 
4557
4559
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/limitLength.js
4558
- var require_limitLength = __commonJS((exports) => {
4560
+ var require_limitLength = __commonJS(function(exports) {
4559
4561
  Object.defineProperty(exports, "__esModule", { value: true });
4560
4562
  var codegen_1 = require_codegen();
4561
4563
  var util_1 = require_util();
@@ -4584,7 +4586,7 @@ var require_limitLength = __commonJS((exports) => {
4584
4586
  });
4585
4587
 
4586
4588
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/pattern.js
4587
- var require_pattern = __commonJS((exports) => {
4589
+ var require_pattern = __commonJS(function(exports) {
4588
4590
  Object.defineProperty(exports, "__esModule", { value: true });
4589
4591
  var code_1 = require_code2();
4590
4592
  var util_1 = require_util();
@@ -4618,7 +4620,7 @@ var require_pattern = __commonJS((exports) => {
4618
4620
  });
4619
4621
 
4620
4622
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
4621
- var require_limitProperties = __commonJS((exports) => {
4623
+ var require_limitProperties = __commonJS(function(exports) {
4622
4624
  Object.defineProperty(exports, "__esModule", { value: true });
4623
4625
  var codegen_1 = require_codegen();
4624
4626
  var error2 = {
@@ -4644,7 +4646,7 @@ var require_limitProperties = __commonJS((exports) => {
4644
4646
  });
4645
4647
 
4646
4648
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/required.js
4647
- var require_required = __commonJS((exports) => {
4649
+ var require_required = __commonJS(function(exports) {
4648
4650
  Object.defineProperty(exports, "__esModule", { value: true });
4649
4651
  var code_1 = require_code2();
4650
4652
  var codegen_1 = require_codegen();
@@ -4723,7 +4725,7 @@ var require_required = __commonJS((exports) => {
4723
4725
  });
4724
4726
 
4725
4727
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/limitItems.js
4726
- var require_limitItems = __commonJS((exports) => {
4728
+ var require_limitItems = __commonJS(function(exports) {
4727
4729
  Object.defineProperty(exports, "__esModule", { value: true });
4728
4730
  var codegen_1 = require_codegen();
4729
4731
  var error2 = {
@@ -4749,7 +4751,7 @@ var require_limitItems = __commonJS((exports) => {
4749
4751
  });
4750
4752
 
4751
4753
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/equal.js
4752
- var require_equal = __commonJS((exports) => {
4754
+ var require_equal = __commonJS(function(exports) {
4753
4755
  Object.defineProperty(exports, "__esModule", { value: true });
4754
4756
  var equal = require_fast_deep_equal();
4755
4757
  equal.code = 'require("ajv/dist/runtime/equal").default';
@@ -4757,7 +4759,7 @@ var require_equal = __commonJS((exports) => {
4757
4759
  });
4758
4760
 
4759
4761
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
4760
- var require_uniqueItems = __commonJS((exports) => {
4762
+ var require_uniqueItems = __commonJS(function(exports) {
4761
4763
  Object.defineProperty(exports, "__esModule", { value: true });
4762
4764
  var dataType_1 = require_dataType();
4763
4765
  var codegen_1 = require_codegen();
@@ -4821,7 +4823,7 @@ var require_uniqueItems = __commonJS((exports) => {
4821
4823
  });
4822
4824
 
4823
4825
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/const.js
4824
- var require_const = __commonJS((exports) => {
4826
+ var require_const = __commonJS(function(exports) {
4825
4827
  Object.defineProperty(exports, "__esModule", { value: true });
4826
4828
  var codegen_1 = require_codegen();
4827
4829
  var util_1 = require_util();
@@ -4847,7 +4849,7 @@ var require_const = __commonJS((exports) => {
4847
4849
  });
4848
4850
 
4849
4851
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/enum.js
4850
- var require_enum = __commonJS((exports) => {
4852
+ var require_enum = __commonJS(function(exports) {
4851
4853
  Object.defineProperty(exports, "__esModule", { value: true });
4852
4854
  var codegen_1 = require_codegen();
4853
4855
  var util_1 = require_util();
@@ -4893,7 +4895,7 @@ var require_enum = __commonJS((exports) => {
4893
4895
  });
4894
4896
 
4895
4897
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/index.js
4896
- var require_validation = __commonJS((exports) => {
4898
+ var require_validation = __commonJS(function(exports) {
4897
4899
  Object.defineProperty(exports, "__esModule", { value: true });
4898
4900
  var limitNumber_1 = require_limitNumber();
4899
4901
  var multipleOf_1 = require_multipleOf();
@@ -4923,7 +4925,7 @@ var require_validation = __commonJS((exports) => {
4923
4925
  });
4924
4926
 
4925
4927
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
4926
- var require_additionalItems = __commonJS((exports) => {
4928
+ var require_additionalItems = __commonJS(function(exports) {
4927
4929
  Object.defineProperty(exports, "__esModule", { value: true });
4928
4930
  exports.validateAdditionalItems = undefined;
4929
4931
  var codegen_1 = require_codegen();
@@ -4973,7 +4975,7 @@ var require_additionalItems = __commonJS((exports) => {
4973
4975
  });
4974
4976
 
4975
4977
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/items.js
4976
- var require_items = __commonJS((exports) => {
4978
+ var require_items = __commonJS(function(exports) {
4977
4979
  Object.defineProperty(exports, "__esModule", { value: true });
4978
4980
  exports.validateTuple = undefined;
4979
4981
  var codegen_1 = require_codegen();
@@ -5027,7 +5029,7 @@ var require_items = __commonJS((exports) => {
5027
5029
  });
5028
5030
 
5029
5031
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
5030
- var require_prefixItems = __commonJS((exports) => {
5032
+ var require_prefixItems = __commonJS(function(exports) {
5031
5033
  Object.defineProperty(exports, "__esModule", { value: true });
5032
5034
  var items_1 = require_items();
5033
5035
  var def = {
@@ -5041,7 +5043,7 @@ var require_prefixItems = __commonJS((exports) => {
5041
5043
  });
5042
5044
 
5043
5045
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/items2020.js
5044
- var require_items2020 = __commonJS((exports) => {
5046
+ var require_items2020 = __commonJS(function(exports) {
5045
5047
  Object.defineProperty(exports, "__esModule", { value: true });
5046
5048
  var codegen_1 = require_codegen();
5047
5049
  var util_1 = require_util();
@@ -5073,7 +5075,7 @@ var require_items2020 = __commonJS((exports) => {
5073
5075
  });
5074
5076
 
5075
5077
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/contains.js
5076
- var require_contains = __commonJS((exports) => {
5078
+ var require_contains = __commonJS(function(exports) {
5077
5079
  Object.defineProperty(exports, "__esModule", { value: true });
5078
5080
  var codegen_1 = require_codegen();
5079
5081
  var util_1 = require_util();
@@ -5164,7 +5166,7 @@ var require_contains = __commonJS((exports) => {
5164
5166
  });
5165
5167
 
5166
5168
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
5167
- var require_dependencies = __commonJS((exports) => {
5169
+ var require_dependencies = __commonJS(function(exports) {
5168
5170
  Object.defineProperty(exports, "__esModule", { value: true });
5169
5171
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = undefined;
5170
5172
  var codegen_1 = require_codegen();
@@ -5249,7 +5251,7 @@ var require_dependencies = __commonJS((exports) => {
5249
5251
  });
5250
5252
 
5251
5253
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
5252
- var require_propertyNames = __commonJS((exports) => {
5254
+ var require_propertyNames = __commonJS(function(exports) {
5253
5255
  Object.defineProperty(exports, "__esModule", { value: true });
5254
5256
  var codegen_1 = require_codegen();
5255
5257
  var util_1 = require_util();
@@ -5289,7 +5291,7 @@ var require_propertyNames = __commonJS((exports) => {
5289
5291
  });
5290
5292
 
5291
5293
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
5292
- var require_additionalProperties = __commonJS((exports) => {
5294
+ var require_additionalProperties = __commonJS(function(exports) {
5293
5295
  Object.defineProperty(exports, "__esModule", { value: true });
5294
5296
  var code_1 = require_code2();
5295
5297
  var codegen_1 = require_codegen();
@@ -5392,7 +5394,7 @@ var require_additionalProperties = __commonJS((exports) => {
5392
5394
  });
5393
5395
 
5394
5396
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/properties.js
5395
- var require_properties = __commonJS((exports) => {
5397
+ var require_properties = __commonJS(function(exports) {
5396
5398
  Object.defineProperty(exports, "__esModule", { value: true });
5397
5399
  var validate_1 = require_validate();
5398
5400
  var code_1 = require_code2();
@@ -5447,7 +5449,7 @@ var require_properties = __commonJS((exports) => {
5447
5449
  });
5448
5450
 
5449
5451
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
5450
- var require_patternProperties = __commonJS((exports) => {
5452
+ var require_patternProperties = __commonJS(function(exports) {
5451
5453
  Object.defineProperty(exports, "__esModule", { value: true });
5452
5454
  var code_1 = require_code2();
5453
5455
  var codegen_1 = require_codegen();
@@ -5518,7 +5520,7 @@ var require_patternProperties = __commonJS((exports) => {
5518
5520
  });
5519
5521
 
5520
5522
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/not.js
5521
- var require_not = __commonJS((exports) => {
5523
+ var require_not = __commonJS(function(exports) {
5522
5524
  Object.defineProperty(exports, "__esModule", { value: true });
5523
5525
  var util_1 = require_util();
5524
5526
  var def = {
@@ -5546,7 +5548,7 @@ var require_not = __commonJS((exports) => {
5546
5548
  });
5547
5549
 
5548
5550
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
5549
- var require_anyOf = __commonJS((exports) => {
5551
+ var require_anyOf = __commonJS(function(exports) {
5550
5552
  Object.defineProperty(exports, "__esModule", { value: true });
5551
5553
  var code_1 = require_code2();
5552
5554
  var def = {
@@ -5560,7 +5562,7 @@ var require_anyOf = __commonJS((exports) => {
5560
5562
  });
5561
5563
 
5562
5564
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
5563
- var require_oneOf = __commonJS((exports) => {
5565
+ var require_oneOf = __commonJS(function(exports) {
5564
5566
  Object.defineProperty(exports, "__esModule", { value: true });
5565
5567
  var codegen_1 = require_codegen();
5566
5568
  var util_1 = require_util();
@@ -5615,7 +5617,7 @@ var require_oneOf = __commonJS((exports) => {
5615
5617
  });
5616
5618
 
5617
5619
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/allOf.js
5618
- var require_allOf = __commonJS((exports) => {
5620
+ var require_allOf = __commonJS(function(exports) {
5619
5621
  Object.defineProperty(exports, "__esModule", { value: true });
5620
5622
  var util_1 = require_util();
5621
5623
  var def = {
@@ -5639,7 +5641,7 @@ var require_allOf = __commonJS((exports) => {
5639
5641
  });
5640
5642
 
5641
5643
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/if.js
5642
- var require_if = __commonJS((exports) => {
5644
+ var require_if = __commonJS(function(exports) {
5643
5645
  Object.defineProperty(exports, "__esModule", { value: true });
5644
5646
  var codegen_1 = require_codegen();
5645
5647
  var util_1 = require_util();
@@ -5705,7 +5707,7 @@ var require_if = __commonJS((exports) => {
5705
5707
  });
5706
5708
 
5707
5709
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
5708
- var require_thenElse = __commonJS((exports) => {
5710
+ var require_thenElse = __commonJS(function(exports) {
5709
5711
  Object.defineProperty(exports, "__esModule", { value: true });
5710
5712
  var util_1 = require_util();
5711
5713
  var def = {
@@ -5720,7 +5722,7 @@ var require_thenElse = __commonJS((exports) => {
5720
5722
  });
5721
5723
 
5722
5724
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/index.js
5723
- var require_applicator = __commonJS((exports) => {
5725
+ var require_applicator = __commonJS(function(exports) {
5724
5726
  Object.defineProperty(exports, "__esModule", { value: true });
5725
5727
  var additionalItems_1 = require_additionalItems();
5726
5728
  var prefixItems_1 = require_prefixItems();
@@ -5763,7 +5765,7 @@ var require_applicator = __commonJS((exports) => {
5763
5765
  });
5764
5766
 
5765
5767
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/format/format.js
5766
- var require_format = __commonJS((exports) => {
5768
+ var require_format = __commonJS(function(exports) {
5767
5769
  Object.defineProperty(exports, "__esModule", { value: true });
5768
5770
  var codegen_1 = require_codegen();
5769
5771
  var error2 = {
@@ -5850,7 +5852,7 @@ var require_format = __commonJS((exports) => {
5850
5852
  });
5851
5853
 
5852
5854
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/format/index.js
5853
- var require_format2 = __commonJS((exports) => {
5855
+ var require_format2 = __commonJS(function(exports) {
5854
5856
  Object.defineProperty(exports, "__esModule", { value: true });
5855
5857
  var format_1 = require_format();
5856
5858
  var format = [format_1.default];
@@ -5858,7 +5860,7 @@ var require_format2 = __commonJS((exports) => {
5858
5860
  });
5859
5861
 
5860
5862
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/metadata.js
5861
- var require_metadata = __commonJS((exports) => {
5863
+ var require_metadata = __commonJS(function(exports) {
5862
5864
  Object.defineProperty(exports, "__esModule", { value: true });
5863
5865
  exports.contentVocabulary = exports.metadataVocabulary = undefined;
5864
5866
  exports.metadataVocabulary = [
@@ -5878,7 +5880,7 @@ var require_metadata = __commonJS((exports) => {
5878
5880
  });
5879
5881
 
5880
5882
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/draft7.js
5881
- var require_draft7 = __commonJS((exports) => {
5883
+ var require_draft7 = __commonJS(function(exports) {
5882
5884
  Object.defineProperty(exports, "__esModule", { value: true });
5883
5885
  var core_1 = require_core2();
5884
5886
  var validation_1 = require_validation();
@@ -5897,7 +5899,7 @@ var require_draft7 = __commonJS((exports) => {
5897
5899
  });
5898
5900
 
5899
5901
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/discriminator/types.js
5900
- var require_types = __commonJS((exports) => {
5902
+ var require_types = __commonJS(function(exports) {
5901
5903
  Object.defineProperty(exports, "__esModule", { value: true });
5902
5904
  exports.DiscrError = undefined;
5903
5905
  var DiscrError;
@@ -5908,7 +5910,7 @@ var require_types = __commonJS((exports) => {
5908
5910
  });
5909
5911
 
5910
5912
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/discriminator/index.js
5911
- var require_discriminator = __commonJS((exports) => {
5913
+ var require_discriminator = __commonJS(function(exports) {
5912
5914
  Object.defineProperty(exports, "__esModule", { value: true });
5913
5915
  var codegen_1 = require_codegen();
5914
5916
  var types_1 = require_types();
@@ -6010,7 +6012,7 @@ var require_discriminator = __commonJS((exports) => {
6010
6012
  });
6011
6013
 
6012
6014
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/refs/json-schema-draft-07.json
6013
- var require_json_schema_draft_07 = __commonJS((exports, module) => {
6015
+ var require_json_schema_draft_07 = __commonJS(function(exports, module) {
6014
6016
  module.exports = {
6015
6017
  $schema: "http://json-schema.org/draft-07/schema#",
6016
6018
  $id: "http://json-schema.org/draft-07/schema#",
@@ -6165,7 +6167,7 @@ var require_json_schema_draft_07 = __commonJS((exports, module) => {
6165
6167
  });
6166
6168
 
6167
6169
  // node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/ajv.js
6168
- var require_ajv = __commonJS((exports, module) => {
6170
+ var require_ajv = __commonJS(function(exports, module) {
6169
6171
  Object.defineProperty(exports, "__esModule", { value: true });
6170
6172
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = undefined;
6171
6173
  var core_1 = require_core();
@@ -6233,7 +6235,7 @@ var require_ajv = __commonJS((exports, module) => {
6233
6235
  });
6234
6236
 
6235
6237
  // node_modules/ajv-formats/dist/formats.js
6236
- var require_formats = __commonJS((exports) => {
6238
+ var require_formats = __commonJS(function(exports) {
6237
6239
  Object.defineProperty(exports, "__esModule", { value: true });
6238
6240
  exports.formatNames = exports.fastFormats = exports.fullFormats = undefined;
6239
6241
  function fmtDef(validate, compare) {
@@ -6410,7 +6412,7 @@ var require_formats = __commonJS((exports) => {
6410
6412
  });
6411
6413
 
6412
6414
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/code.js
6413
- var require_code3 = __commonJS((exports) => {
6415
+ var require_code3 = __commonJS(function(exports) {
6414
6416
  Object.defineProperty(exports, "__esModule", { value: true });
6415
6417
  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 = undefined;
6416
6418
 
@@ -6564,7 +6566,7 @@ var require_code3 = __commonJS((exports) => {
6564
6566
  });
6565
6567
 
6566
6568
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/scope.js
6567
- var require_scope2 = __commonJS((exports) => {
6569
+ var require_scope2 = __commonJS(function(exports) {
6568
6570
  Object.defineProperty(exports, "__esModule", { value: true });
6569
6571
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = undefined;
6570
6572
  var code_1 = require_code3();
@@ -6710,7 +6712,7 @@ var require_scope2 = __commonJS((exports) => {
6710
6712
  });
6711
6713
 
6712
6714
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/index.js
6713
- var require_codegen2 = __commonJS((exports) => {
6715
+ var require_codegen2 = __commonJS(function(exports) {
6714
6716
  Object.defineProperty(exports, "__esModule", { value: true });
6715
6717
  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._ = undefined;
6716
6718
  var code_1 = require_code3();
@@ -7420,7 +7422,7 @@ var require_codegen2 = __commonJS((exports) => {
7420
7422
  });
7421
7423
 
7422
7424
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/util.js
7423
- var require_util2 = __commonJS((exports) => {
7425
+ var require_util2 = __commonJS(function(exports) {
7424
7426
  Object.defineProperty(exports, "__esModule", { value: true });
7425
7427
  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 = undefined;
7426
7428
  var codegen_1 = require_codegen2();
@@ -7584,7 +7586,7 @@ var require_util2 = __commonJS((exports) => {
7584
7586
  });
7585
7587
 
7586
7588
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/names.js
7587
- var require_names2 = __commonJS((exports) => {
7589
+ var require_names2 = __commonJS(function(exports) {
7588
7590
  Object.defineProperty(exports, "__esModule", { value: true });
7589
7591
  var codegen_1 = require_codegen2();
7590
7592
  var names = {
@@ -7609,7 +7611,7 @@ var require_names2 = __commonJS((exports) => {
7609
7611
  });
7610
7612
 
7611
7613
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/errors.js
7612
- var require_errors2 = __commonJS((exports) => {
7614
+ var require_errors2 = __commonJS(function(exports) {
7613
7615
  Object.defineProperty(exports, "__esModule", { value: true });
7614
7616
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = undefined;
7615
7617
  var codegen_1 = require_codegen2();
@@ -7727,7 +7729,7 @@ var require_errors2 = __commonJS((exports) => {
7727
7729
  });
7728
7730
 
7729
7731
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/boolSchema.js
7730
- var require_boolSchema2 = __commonJS((exports) => {
7732
+ var require_boolSchema2 = __commonJS(function(exports) {
7731
7733
  Object.defineProperty(exports, "__esModule", { value: true });
7732
7734
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = undefined;
7733
7735
  var errors_1 = require_errors2();
@@ -7775,7 +7777,7 @@ var require_boolSchema2 = __commonJS((exports) => {
7775
7777
  });
7776
7778
 
7777
7779
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/rules.js
7778
- var require_rules2 = __commonJS((exports) => {
7780
+ var require_rules2 = __commonJS(function(exports) {
7779
7781
  Object.defineProperty(exports, "__esModule", { value: true });
7780
7782
  exports.getRules = exports.isJSONType = undefined;
7781
7783
  var _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"];
@@ -7803,7 +7805,7 @@ var require_rules2 = __commonJS((exports) => {
7803
7805
  });
7804
7806
 
7805
7807
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/applicability.js
7806
- var require_applicability2 = __commonJS((exports) => {
7808
+ var require_applicability2 = __commonJS(function(exports) {
7807
7809
  Object.defineProperty(exports, "__esModule", { value: true });
7808
7810
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = undefined;
7809
7811
  function schemaHasRulesForType({ schema, self }, type) {
@@ -7823,7 +7825,7 @@ var require_applicability2 = __commonJS((exports) => {
7823
7825
  });
7824
7826
 
7825
7827
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/dataType.js
7826
- var require_dataType2 = __commonJS((exports) => {
7828
+ var require_dataType2 = __commonJS(function(exports) {
7827
7829
  Object.defineProperty(exports, "__esModule", { value: true });
7828
7830
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = undefined;
7829
7831
  var rules_1 = require_rules2();
@@ -8004,7 +8006,7 @@ var require_dataType2 = __commonJS((exports) => {
8004
8006
  });
8005
8007
 
8006
8008
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/defaults.js
8007
- var require_defaults2 = __commonJS((exports) => {
8009
+ var require_defaults2 = __commonJS(function(exports) {
8008
8010
  Object.defineProperty(exports, "__esModule", { value: true });
8009
8011
  exports.assignDefaults = undefined;
8010
8012
  var codegen_1 = require_codegen2();
@@ -8038,7 +8040,7 @@ var require_defaults2 = __commonJS((exports) => {
8038
8040
  });
8039
8041
 
8040
8042
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/code.js
8041
- var require_code4 = __commonJS((exports) => {
8043
+ var require_code4 = __commonJS(function(exports) {
8042
8044
  Object.defineProperty(exports, "__esModule", { value: true });
8043
8045
  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 = undefined;
8044
8046
  var codegen_1 = require_codegen2();
@@ -8167,7 +8169,7 @@ var require_code4 = __commonJS((exports) => {
8167
8169
  });
8168
8170
 
8169
8171
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/keyword.js
8170
- var require_keyword2 = __commonJS((exports) => {
8172
+ var require_keyword2 = __commonJS(function(exports) {
8171
8173
  Object.defineProperty(exports, "__esModule", { value: true });
8172
8174
  exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = undefined;
8173
8175
  var codegen_1 = require_codegen2();
@@ -8282,7 +8284,7 @@ var require_keyword2 = __commonJS((exports) => {
8282
8284
  });
8283
8285
 
8284
8286
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/subschema.js
8285
- var require_subschema2 = __commonJS((exports) => {
8287
+ var require_subschema2 = __commonJS(function(exports) {
8286
8288
  Object.defineProperty(exports, "__esModule", { value: true });
8287
8289
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = undefined;
8288
8290
  var codegen_1 = require_codegen2();
@@ -8362,7 +8364,7 @@ var require_subschema2 = __commonJS((exports) => {
8362
8364
  });
8363
8365
 
8364
8366
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/resolve.js
8365
- var require_resolve2 = __commonJS((exports) => {
8367
+ var require_resolve2 = __commonJS(function(exports) {
8366
8368
  Object.defineProperty(exports, "__esModule", { value: true });
8367
8369
  exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = undefined;
8368
8370
  var util_1 = require_util2();
@@ -8515,7 +8517,7 @@ var require_resolve2 = __commonJS((exports) => {
8515
8517
  });
8516
8518
 
8517
8519
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/index.js
8518
- var require_validate2 = __commonJS((exports) => {
8520
+ var require_validate2 = __commonJS(function(exports) {
8519
8521
  Object.defineProperty(exports, "__esModule", { value: true });
8520
8522
  exports.getData = exports.KeywordCxt = exports.validateFunctionCode = undefined;
8521
8523
  var boolSchema_1 = require_boolSchema2();
@@ -9020,7 +9022,7 @@ var require_validate2 = __commonJS((exports) => {
9020
9022
  });
9021
9023
 
9022
9024
  // node_modules/ajv-formats/node_modules/ajv/dist/runtime/validation_error.js
9023
- var require_validation_error2 = __commonJS((exports) => {
9025
+ var require_validation_error2 = __commonJS(function(exports) {
9024
9026
  Object.defineProperty(exports, "__esModule", { value: true });
9025
9027
 
9026
9028
  class ValidationError extends Error {
@@ -9034,7 +9036,7 @@ var require_validation_error2 = __commonJS((exports) => {
9034
9036
  });
9035
9037
 
9036
9038
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/ref_error.js
9037
- var require_ref_error2 = __commonJS((exports) => {
9039
+ var require_ref_error2 = __commonJS(function(exports) {
9038
9040
  Object.defineProperty(exports, "__esModule", { value: true });
9039
9041
  var resolve_1 = require_resolve2();
9040
9042
 
@@ -9049,7 +9051,7 @@ var require_ref_error2 = __commonJS((exports) => {
9049
9051
  });
9050
9052
 
9051
9053
  // node_modules/ajv-formats/node_modules/ajv/dist/compile/index.js
9052
- var require_compile2 = __commonJS((exports) => {
9054
+ var require_compile2 = __commonJS(function(exports) {
9053
9055
  Object.defineProperty(exports, "__esModule", { value: true });
9054
9056
  exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = undefined;
9055
9057
  var codegen_1 = require_codegen2();
@@ -9270,7 +9272,7 @@ var require_compile2 = __commonJS((exports) => {
9270
9272
  });
9271
9273
 
9272
9274
  // node_modules/ajv-formats/node_modules/ajv/dist/refs/data.json
9273
- var require_data2 = __commonJS((exports, module) => {
9275
+ var require_data2 = __commonJS(function(exports, module) {
9274
9276
  module.exports = {
9275
9277
  $id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
9276
9278
  description: "Meta-schema for $data reference (JSON AnySchema extension proposal)",
@@ -9287,7 +9289,7 @@ var require_data2 = __commonJS((exports, module) => {
9287
9289
  });
9288
9290
 
9289
9291
  // node_modules/ajv-formats/node_modules/ajv/dist/runtime/uri.js
9290
- var require_uri2 = __commonJS((exports) => {
9292
+ var require_uri2 = __commonJS(function(exports) {
9291
9293
  Object.defineProperty(exports, "__esModule", { value: true });
9292
9294
  var uri = require_fast_uri();
9293
9295
  uri.code = 'require("ajv/dist/runtime/uri").default';
@@ -9295,7 +9297,7 @@ var require_uri2 = __commonJS((exports) => {
9295
9297
  });
9296
9298
 
9297
9299
  // node_modules/ajv-formats/node_modules/ajv/dist/core.js
9298
- var require_core3 = __commonJS((exports) => {
9300
+ var require_core3 = __commonJS(function(exports) {
9299
9301
  Object.defineProperty(exports, "__esModule", { value: true });
9300
9302
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = undefined;
9301
9303
  var validate_1 = require_validate2();
@@ -9888,7 +9890,7 @@ var require_core3 = __commonJS((exports) => {
9888
9890
  });
9889
9891
 
9890
9892
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/core/id.js
9891
- var require_id2 = __commonJS((exports) => {
9893
+ var require_id2 = __commonJS(function(exports) {
9892
9894
  Object.defineProperty(exports, "__esModule", { value: true });
9893
9895
  var def = {
9894
9896
  keyword: "id",
@@ -9900,7 +9902,7 @@ var require_id2 = __commonJS((exports) => {
9900
9902
  });
9901
9903
 
9902
9904
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/core/ref.js
9903
- var require_ref2 = __commonJS((exports) => {
9905
+ var require_ref2 = __commonJS(function(exports) {
9904
9906
  Object.defineProperty(exports, "__esModule", { value: true });
9905
9907
  exports.callRef = exports.getValidate = undefined;
9906
9908
  var ref_error_1 = require_ref_error2();
@@ -10019,7 +10021,7 @@ var require_ref2 = __commonJS((exports) => {
10019
10021
  });
10020
10022
 
10021
10023
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/core/index.js
10022
- var require_core4 = __commonJS((exports) => {
10024
+ var require_core4 = __commonJS(function(exports) {
10023
10025
  Object.defineProperty(exports, "__esModule", { value: true });
10024
10026
  var id_1 = require_id2();
10025
10027
  var ref_1 = require_ref2();
@@ -10037,7 +10039,7 @@ var require_core4 = __commonJS((exports) => {
10037
10039
  });
10038
10040
 
10039
10041
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
10040
- var require_limitNumber2 = __commonJS((exports) => {
10042
+ var require_limitNumber2 = __commonJS(function(exports) {
10041
10043
  Object.defineProperty(exports, "__esModule", { value: true });
10042
10044
  var codegen_1 = require_codegen2();
10043
10045
  var ops = codegen_1.operators;
@@ -10066,7 +10068,7 @@ var require_limitNumber2 = __commonJS((exports) => {
10066
10068
  });
10067
10069
 
10068
10070
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
10069
- var require_multipleOf2 = __commonJS((exports) => {
10071
+ var require_multipleOf2 = __commonJS(function(exports) {
10070
10072
  Object.defineProperty(exports, "__esModule", { value: true });
10071
10073
  var codegen_1 = require_codegen2();
10072
10074
  var error2 = {
@@ -10091,7 +10093,7 @@ var require_multipleOf2 = __commonJS((exports) => {
10091
10093
  });
10092
10094
 
10093
10095
  // node_modules/ajv-formats/node_modules/ajv/dist/runtime/ucs2length.js
10094
- var require_ucs2length2 = __commonJS((exports) => {
10096
+ var require_ucs2length2 = __commonJS(function(exports) {
10095
10097
  Object.defineProperty(exports, "__esModule", { value: true });
10096
10098
  function ucs2length(str) {
10097
10099
  const len = str.length;
@@ -10114,7 +10116,7 @@ var require_ucs2length2 = __commonJS((exports) => {
10114
10116
  });
10115
10117
 
10116
10118
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/limitLength.js
10117
- var require_limitLength2 = __commonJS((exports) => {
10119
+ var require_limitLength2 = __commonJS(function(exports) {
10118
10120
  Object.defineProperty(exports, "__esModule", { value: true });
10119
10121
  var codegen_1 = require_codegen2();
10120
10122
  var util_1 = require_util2();
@@ -10143,7 +10145,7 @@ var require_limitLength2 = __commonJS((exports) => {
10143
10145
  });
10144
10146
 
10145
10147
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/pattern.js
10146
- var require_pattern2 = __commonJS((exports) => {
10148
+ var require_pattern2 = __commonJS(function(exports) {
10147
10149
  Object.defineProperty(exports, "__esModule", { value: true });
10148
10150
  var code_1 = require_code4();
10149
10151
  var util_1 = require_util2();
@@ -10177,7 +10179,7 @@ var require_pattern2 = __commonJS((exports) => {
10177
10179
  });
10178
10180
 
10179
10181
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
10180
- var require_limitProperties2 = __commonJS((exports) => {
10182
+ var require_limitProperties2 = __commonJS(function(exports) {
10181
10183
  Object.defineProperty(exports, "__esModule", { value: true });
10182
10184
  var codegen_1 = require_codegen2();
10183
10185
  var error2 = {
@@ -10203,7 +10205,7 @@ var require_limitProperties2 = __commonJS((exports) => {
10203
10205
  });
10204
10206
 
10205
10207
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/required.js
10206
- var require_required2 = __commonJS((exports) => {
10208
+ var require_required2 = __commonJS(function(exports) {
10207
10209
  Object.defineProperty(exports, "__esModule", { value: true });
10208
10210
  var code_1 = require_code4();
10209
10211
  var codegen_1 = require_codegen2();
@@ -10282,7 +10284,7 @@ var require_required2 = __commonJS((exports) => {
10282
10284
  });
10283
10285
 
10284
10286
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/limitItems.js
10285
- var require_limitItems2 = __commonJS((exports) => {
10287
+ var require_limitItems2 = __commonJS(function(exports) {
10286
10288
  Object.defineProperty(exports, "__esModule", { value: true });
10287
10289
  var codegen_1 = require_codegen2();
10288
10290
  var error2 = {
@@ -10308,7 +10310,7 @@ var require_limitItems2 = __commonJS((exports) => {
10308
10310
  });
10309
10311
 
10310
10312
  // node_modules/ajv-formats/node_modules/ajv/dist/runtime/equal.js
10311
- var require_equal2 = __commonJS((exports) => {
10313
+ var require_equal2 = __commonJS(function(exports) {
10312
10314
  Object.defineProperty(exports, "__esModule", { value: true });
10313
10315
  var equal = require_fast_deep_equal();
10314
10316
  equal.code = 'require("ajv/dist/runtime/equal").default';
@@ -10316,7 +10318,7 @@ var require_equal2 = __commonJS((exports) => {
10316
10318
  });
10317
10319
 
10318
10320
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
10319
- var require_uniqueItems2 = __commonJS((exports) => {
10321
+ var require_uniqueItems2 = __commonJS(function(exports) {
10320
10322
  Object.defineProperty(exports, "__esModule", { value: true });
10321
10323
  var dataType_1 = require_dataType2();
10322
10324
  var codegen_1 = require_codegen2();
@@ -10380,7 +10382,7 @@ var require_uniqueItems2 = __commonJS((exports) => {
10380
10382
  });
10381
10383
 
10382
10384
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/const.js
10383
- var require_const2 = __commonJS((exports) => {
10385
+ var require_const2 = __commonJS(function(exports) {
10384
10386
  Object.defineProperty(exports, "__esModule", { value: true });
10385
10387
  var codegen_1 = require_codegen2();
10386
10388
  var util_1 = require_util2();
@@ -10406,7 +10408,7 @@ var require_const2 = __commonJS((exports) => {
10406
10408
  });
10407
10409
 
10408
10410
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/enum.js
10409
- var require_enum2 = __commonJS((exports) => {
10411
+ var require_enum2 = __commonJS(function(exports) {
10410
10412
  Object.defineProperty(exports, "__esModule", { value: true });
10411
10413
  var codegen_1 = require_codegen2();
10412
10414
  var util_1 = require_util2();
@@ -10452,7 +10454,7 @@ var require_enum2 = __commonJS((exports) => {
10452
10454
  });
10453
10455
 
10454
10456
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/index.js
10455
- var require_validation2 = __commonJS((exports) => {
10457
+ var require_validation2 = __commonJS(function(exports) {
10456
10458
  Object.defineProperty(exports, "__esModule", { value: true });
10457
10459
  var limitNumber_1 = require_limitNumber2();
10458
10460
  var multipleOf_1 = require_multipleOf2();
@@ -10482,7 +10484,7 @@ var require_validation2 = __commonJS((exports) => {
10482
10484
  });
10483
10485
 
10484
10486
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
10485
- var require_additionalItems2 = __commonJS((exports) => {
10487
+ var require_additionalItems2 = __commonJS(function(exports) {
10486
10488
  Object.defineProperty(exports, "__esModule", { value: true });
10487
10489
  exports.validateAdditionalItems = undefined;
10488
10490
  var codegen_1 = require_codegen2();
@@ -10532,7 +10534,7 @@ var require_additionalItems2 = __commonJS((exports) => {
10532
10534
  });
10533
10535
 
10534
10536
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/items.js
10535
- var require_items2 = __commonJS((exports) => {
10537
+ var require_items2 = __commonJS(function(exports) {
10536
10538
  Object.defineProperty(exports, "__esModule", { value: true });
10537
10539
  exports.validateTuple = undefined;
10538
10540
  var codegen_1 = require_codegen2();
@@ -10586,7 +10588,7 @@ var require_items2 = __commonJS((exports) => {
10586
10588
  });
10587
10589
 
10588
10590
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
10589
- var require_prefixItems2 = __commonJS((exports) => {
10591
+ var require_prefixItems2 = __commonJS(function(exports) {
10590
10592
  Object.defineProperty(exports, "__esModule", { value: true });
10591
10593
  var items_1 = require_items2();
10592
10594
  var def = {
@@ -10600,7 +10602,7 @@ var require_prefixItems2 = __commonJS((exports) => {
10600
10602
  });
10601
10603
 
10602
10604
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/items2020.js
10603
- var require_items20202 = __commonJS((exports) => {
10605
+ var require_items20202 = __commonJS(function(exports) {
10604
10606
  Object.defineProperty(exports, "__esModule", { value: true });
10605
10607
  var codegen_1 = require_codegen2();
10606
10608
  var util_1 = require_util2();
@@ -10632,7 +10634,7 @@ var require_items20202 = __commonJS((exports) => {
10632
10634
  });
10633
10635
 
10634
10636
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/contains.js
10635
- var require_contains2 = __commonJS((exports) => {
10637
+ var require_contains2 = __commonJS(function(exports) {
10636
10638
  Object.defineProperty(exports, "__esModule", { value: true });
10637
10639
  var codegen_1 = require_codegen2();
10638
10640
  var util_1 = require_util2();
@@ -10723,7 +10725,7 @@ var require_contains2 = __commonJS((exports) => {
10723
10725
  });
10724
10726
 
10725
10727
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
10726
- var require_dependencies2 = __commonJS((exports) => {
10728
+ var require_dependencies2 = __commonJS(function(exports) {
10727
10729
  Object.defineProperty(exports, "__esModule", { value: true });
10728
10730
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = undefined;
10729
10731
  var codegen_1 = require_codegen2();
@@ -10808,7 +10810,7 @@ var require_dependencies2 = __commonJS((exports) => {
10808
10810
  });
10809
10811
 
10810
10812
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
10811
- var require_propertyNames2 = __commonJS((exports) => {
10813
+ var require_propertyNames2 = __commonJS(function(exports) {
10812
10814
  Object.defineProperty(exports, "__esModule", { value: true });
10813
10815
  var codegen_1 = require_codegen2();
10814
10816
  var util_1 = require_util2();
@@ -10848,7 +10850,7 @@ var require_propertyNames2 = __commonJS((exports) => {
10848
10850
  });
10849
10851
 
10850
10852
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
10851
- var require_additionalProperties2 = __commonJS((exports) => {
10853
+ var require_additionalProperties2 = __commonJS(function(exports) {
10852
10854
  Object.defineProperty(exports, "__esModule", { value: true });
10853
10855
  var code_1 = require_code4();
10854
10856
  var codegen_1 = require_codegen2();
@@ -10951,7 +10953,7 @@ var require_additionalProperties2 = __commonJS((exports) => {
10951
10953
  });
10952
10954
 
10953
10955
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/properties.js
10954
- var require_properties2 = __commonJS((exports) => {
10956
+ var require_properties2 = __commonJS(function(exports) {
10955
10957
  Object.defineProperty(exports, "__esModule", { value: true });
10956
10958
  var validate_1 = require_validate2();
10957
10959
  var code_1 = require_code4();
@@ -11006,7 +11008,7 @@ var require_properties2 = __commonJS((exports) => {
11006
11008
  });
11007
11009
 
11008
11010
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
11009
- var require_patternProperties2 = __commonJS((exports) => {
11011
+ var require_patternProperties2 = __commonJS(function(exports) {
11010
11012
  Object.defineProperty(exports, "__esModule", { value: true });
11011
11013
  var code_1 = require_code4();
11012
11014
  var codegen_1 = require_codegen2();
@@ -11077,7 +11079,7 @@ var require_patternProperties2 = __commonJS((exports) => {
11077
11079
  });
11078
11080
 
11079
11081
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/not.js
11080
- var require_not2 = __commonJS((exports) => {
11082
+ var require_not2 = __commonJS(function(exports) {
11081
11083
  Object.defineProperty(exports, "__esModule", { value: true });
11082
11084
  var util_1 = require_util2();
11083
11085
  var def = {
@@ -11105,7 +11107,7 @@ var require_not2 = __commonJS((exports) => {
11105
11107
  });
11106
11108
 
11107
11109
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
11108
- var require_anyOf2 = __commonJS((exports) => {
11110
+ var require_anyOf2 = __commonJS(function(exports) {
11109
11111
  Object.defineProperty(exports, "__esModule", { value: true });
11110
11112
  var code_1 = require_code4();
11111
11113
  var def = {
@@ -11119,7 +11121,7 @@ var require_anyOf2 = __commonJS((exports) => {
11119
11121
  });
11120
11122
 
11121
11123
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
11122
- var require_oneOf2 = __commonJS((exports) => {
11124
+ var require_oneOf2 = __commonJS(function(exports) {
11123
11125
  Object.defineProperty(exports, "__esModule", { value: true });
11124
11126
  var codegen_1 = require_codegen2();
11125
11127
  var util_1 = require_util2();
@@ -11174,7 +11176,7 @@ var require_oneOf2 = __commonJS((exports) => {
11174
11176
  });
11175
11177
 
11176
11178
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/allOf.js
11177
- var require_allOf2 = __commonJS((exports) => {
11179
+ var require_allOf2 = __commonJS(function(exports) {
11178
11180
  Object.defineProperty(exports, "__esModule", { value: true });
11179
11181
  var util_1 = require_util2();
11180
11182
  var def = {
@@ -11198,7 +11200,7 @@ var require_allOf2 = __commonJS((exports) => {
11198
11200
  });
11199
11201
 
11200
11202
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/if.js
11201
- var require_if2 = __commonJS((exports) => {
11203
+ var require_if2 = __commonJS(function(exports) {
11202
11204
  Object.defineProperty(exports, "__esModule", { value: true });
11203
11205
  var codegen_1 = require_codegen2();
11204
11206
  var util_1 = require_util2();
@@ -11264,7 +11266,7 @@ var require_if2 = __commonJS((exports) => {
11264
11266
  });
11265
11267
 
11266
11268
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
11267
- var require_thenElse2 = __commonJS((exports) => {
11269
+ var require_thenElse2 = __commonJS(function(exports) {
11268
11270
  Object.defineProperty(exports, "__esModule", { value: true });
11269
11271
  var util_1 = require_util2();
11270
11272
  var def = {
@@ -11279,7 +11281,7 @@ var require_thenElse2 = __commonJS((exports) => {
11279
11281
  });
11280
11282
 
11281
11283
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/index.js
11282
- var require_applicator2 = __commonJS((exports) => {
11284
+ var require_applicator2 = __commonJS(function(exports) {
11283
11285
  Object.defineProperty(exports, "__esModule", { value: true });
11284
11286
  var additionalItems_1 = require_additionalItems2();
11285
11287
  var prefixItems_1 = require_prefixItems2();
@@ -11322,7 +11324,7 @@ var require_applicator2 = __commonJS((exports) => {
11322
11324
  });
11323
11325
 
11324
11326
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/format/format.js
11325
- var require_format3 = __commonJS((exports) => {
11327
+ var require_format3 = __commonJS(function(exports) {
11326
11328
  Object.defineProperty(exports, "__esModule", { value: true });
11327
11329
  var codegen_1 = require_codegen2();
11328
11330
  var error2 = {
@@ -11409,7 +11411,7 @@ var require_format3 = __commonJS((exports) => {
11409
11411
  });
11410
11412
 
11411
11413
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/format/index.js
11412
- var require_format4 = __commonJS((exports) => {
11414
+ var require_format4 = __commonJS(function(exports) {
11413
11415
  Object.defineProperty(exports, "__esModule", { value: true });
11414
11416
  var format_1 = require_format3();
11415
11417
  var format = [format_1.default];
@@ -11417,7 +11419,7 @@ var require_format4 = __commonJS((exports) => {
11417
11419
  });
11418
11420
 
11419
11421
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/metadata.js
11420
- var require_metadata2 = __commonJS((exports) => {
11422
+ var require_metadata2 = __commonJS(function(exports) {
11421
11423
  Object.defineProperty(exports, "__esModule", { value: true });
11422
11424
  exports.contentVocabulary = exports.metadataVocabulary = undefined;
11423
11425
  exports.metadataVocabulary = [
@@ -11437,7 +11439,7 @@ var require_metadata2 = __commonJS((exports) => {
11437
11439
  });
11438
11440
 
11439
11441
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/draft7.js
11440
- var require_draft72 = __commonJS((exports) => {
11442
+ var require_draft72 = __commonJS(function(exports) {
11441
11443
  Object.defineProperty(exports, "__esModule", { value: true });
11442
11444
  var core_1 = require_core4();
11443
11445
  var validation_1 = require_validation2();
@@ -11456,7 +11458,7 @@ var require_draft72 = __commonJS((exports) => {
11456
11458
  });
11457
11459
 
11458
11460
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/types.js
11459
- var require_types2 = __commonJS((exports) => {
11461
+ var require_types2 = __commonJS(function(exports) {
11460
11462
  Object.defineProperty(exports, "__esModule", { value: true });
11461
11463
  exports.DiscrError = undefined;
11462
11464
  var DiscrError;
@@ -11467,7 +11469,7 @@ var require_types2 = __commonJS((exports) => {
11467
11469
  });
11468
11470
 
11469
11471
  // node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/index.js
11470
- var require_discriminator2 = __commonJS((exports) => {
11472
+ var require_discriminator2 = __commonJS(function(exports) {
11471
11473
  Object.defineProperty(exports, "__esModule", { value: true });
11472
11474
  var codegen_1 = require_codegen2();
11473
11475
  var types_1 = require_types2();
@@ -11569,7 +11571,7 @@ var require_discriminator2 = __commonJS((exports) => {
11569
11571
  });
11570
11572
 
11571
11573
  // node_modules/ajv-formats/node_modules/ajv/dist/refs/json-schema-draft-07.json
11572
- var require_json_schema_draft_072 = __commonJS((exports, module) => {
11574
+ var require_json_schema_draft_072 = __commonJS(function(exports, module) {
11573
11575
  module.exports = {
11574
11576
  $schema: "http://json-schema.org/draft-07/schema#",
11575
11577
  $id: "http://json-schema.org/draft-07/schema#",
@@ -11724,7 +11726,7 @@ var require_json_schema_draft_072 = __commonJS((exports, module) => {
11724
11726
  });
11725
11727
 
11726
11728
  // node_modules/ajv-formats/node_modules/ajv/dist/ajv.js
11727
- var require_ajv2 = __commonJS((exports, module) => {
11729
+ var require_ajv2 = __commonJS(function(exports, module) {
11728
11730
  Object.defineProperty(exports, "__esModule", { value: true });
11729
11731
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = undefined;
11730
11732
  var core_1 = require_core3();
@@ -11792,7 +11794,7 @@ var require_ajv2 = __commonJS((exports, module) => {
11792
11794
  });
11793
11795
 
11794
11796
  // node_modules/ajv-formats/dist/limit.js
11795
- var require_limit = __commonJS((exports) => {
11797
+ var require_limit = __commonJS(function(exports) {
11796
11798
  Object.defineProperty(exports, "__esModule", { value: true });
11797
11799
  exports.formatLimitDefinition = undefined;
11798
11800
  var ajv_1 = require_ajv2();
@@ -11861,7 +11863,7 @@ var require_limit = __commonJS((exports) => {
11861
11863
  });
11862
11864
 
11863
11865
  // node_modules/ajv-formats/dist/index.js
11864
- var require_dist = __commonJS((exports, module) => {
11866
+ var require_dist = __commonJS(function(exports, module) {
11865
11867
  Object.defineProperty(exports, "__esModule", { value: true });
11866
11868
  var formats_1 = require_formats();
11867
11869
  var limit_1 = require_limit();
@@ -11902,113 +11904,113 @@ var require_dist = __commonJS((exports, module) => {
11902
11904
  // node_modules/zod/v3/external.js
11903
11905
  var exports_external = {};
11904
11906
  __export(exports_external, {
11905
- void: () => voidType,
11906
- util: () => util,
11907
- unknown: () => unknownType,
11908
- union: () => unionType,
11909
- undefined: () => undefinedType,
11910
- tuple: () => tupleType,
11911
- transformer: () => effectsType,
11912
- symbol: () => symbolType,
11913
- string: () => stringType,
11914
- strictObject: () => strictObjectType,
11915
- setErrorMap: () => setErrorMap,
11916
- set: () => setType,
11917
- record: () => recordType,
11918
- quotelessJson: () => quotelessJson,
11919
- promise: () => promiseType,
11920
- preprocess: () => preprocessType,
11921
- pipeline: () => pipelineType,
11922
- ostring: () => ostring,
11923
- optional: () => optionalType,
11924
- onumber: () => onumber,
11925
- oboolean: () => oboolean,
11926
- objectUtil: () => objectUtil,
11927
- object: () => objectType,
11928
- number: () => numberType,
11929
- nullable: () => nullableType,
11930
- null: () => nullType,
11931
- never: () => neverType,
11932
- nativeEnum: () => nativeEnumType,
11933
- nan: () => nanType,
11934
- map: () => mapType,
11935
- makeIssue: () => makeIssue,
11936
- literal: () => literalType,
11937
- lazy: () => lazyType,
11938
- late: () => late,
11939
- isValid: () => isValid,
11940
- isDirty: () => isDirty,
11941
- isAsync: () => isAsync,
11942
- isAborted: () => isAborted,
11943
- intersection: () => intersectionType,
11944
- instanceof: () => instanceOfType,
11945
- getParsedType: () => getParsedType,
11946
- getErrorMap: () => getErrorMap,
11947
- function: () => functionType,
11948
- enum: () => enumType,
11949
- effect: () => effectsType,
11950
- discriminatedUnion: () => discriminatedUnionType,
11951
- defaultErrorMap: () => en_default,
11952
- datetimeRegex: () => datetimeRegex,
11953
- date: () => dateType,
11954
- custom: () => custom,
11955
- coerce: () => coerce,
11956
- boolean: () => booleanType,
11957
- bigint: () => bigIntType,
11958
- array: () => arrayType,
11959
- any: () => anyType,
11960
- addIssueToContext: () => addIssueToContext,
11961
- ZodVoid: () => ZodVoid,
11962
- ZodUnknown: () => ZodUnknown,
11963
- ZodUnion: () => ZodUnion,
11964
- ZodUndefined: () => ZodUndefined,
11965
- ZodType: () => ZodType,
11966
- ZodTuple: () => ZodTuple,
11967
- ZodTransformer: () => ZodEffects,
11968
- ZodSymbol: () => ZodSymbol,
11969
- ZodString: () => ZodString,
11970
- ZodSet: () => ZodSet,
11971
- ZodSchema: () => ZodType,
11972
- ZodRecord: () => ZodRecord,
11973
- ZodReadonly: () => ZodReadonly,
11974
- ZodPromise: () => ZodPromise,
11975
- ZodPipeline: () => ZodPipeline,
11976
- ZodParsedType: () => ZodParsedType,
11977
- ZodOptional: () => ZodOptional,
11978
- ZodObject: () => ZodObject,
11979
- ZodNumber: () => ZodNumber,
11980
- ZodNullable: () => ZodNullable,
11981
- ZodNull: () => ZodNull,
11982
- ZodNever: () => ZodNever,
11983
- ZodNativeEnum: () => ZodNativeEnum,
11984
- ZodNaN: () => ZodNaN,
11985
- ZodMap: () => ZodMap,
11986
- ZodLiteral: () => ZodLiteral,
11987
- ZodLazy: () => ZodLazy,
11988
- ZodIssueCode: () => ZodIssueCode,
11989
- ZodIntersection: () => ZodIntersection,
11990
- ZodFunction: () => ZodFunction,
11991
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
11992
- ZodError: () => ZodError,
11993
- ZodEnum: () => ZodEnum,
11994
- ZodEffects: () => ZodEffects,
11995
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
11996
- ZodDefault: () => ZodDefault,
11997
- ZodDate: () => ZodDate,
11998
- ZodCatch: () => ZodCatch,
11999
- ZodBranded: () => ZodBranded,
12000
- ZodBoolean: () => ZodBoolean,
12001
- ZodBigInt: () => ZodBigInt,
12002
- ZodArray: () => ZodArray,
12003
- ZodAny: () => ZodAny,
12004
- Schema: () => ZodType,
12005
- ParseStatus: () => ParseStatus,
12006
- OK: () => OK,
12007
- NEVER: () => NEVER,
12008
- INVALID: () => INVALID,
12009
- EMPTY_PATH: () => EMPTY_PATH,
11907
+ BRAND: () => BRAND,
12010
11908
  DIRTY: () => DIRTY,
12011
- BRAND: () => BRAND
11909
+ EMPTY_PATH: () => EMPTY_PATH,
11910
+ INVALID: () => INVALID,
11911
+ NEVER: () => NEVER,
11912
+ OK: () => OK,
11913
+ ParseStatus: () => ParseStatus,
11914
+ Schema: () => ZodType,
11915
+ ZodAny: () => ZodAny,
11916
+ ZodArray: () => ZodArray,
11917
+ ZodBigInt: () => ZodBigInt,
11918
+ ZodBoolean: () => ZodBoolean,
11919
+ ZodBranded: () => ZodBranded,
11920
+ ZodCatch: () => ZodCatch,
11921
+ ZodDate: () => ZodDate,
11922
+ ZodDefault: () => ZodDefault,
11923
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
11924
+ ZodEffects: () => ZodEffects,
11925
+ ZodEnum: () => ZodEnum,
11926
+ ZodError: () => ZodError,
11927
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
11928
+ ZodFunction: () => ZodFunction,
11929
+ ZodIntersection: () => ZodIntersection,
11930
+ ZodIssueCode: () => ZodIssueCode,
11931
+ ZodLazy: () => ZodLazy,
11932
+ ZodLiteral: () => ZodLiteral,
11933
+ ZodMap: () => ZodMap,
11934
+ ZodNaN: () => ZodNaN,
11935
+ ZodNativeEnum: () => ZodNativeEnum,
11936
+ ZodNever: () => ZodNever,
11937
+ ZodNull: () => ZodNull,
11938
+ ZodNullable: () => ZodNullable,
11939
+ ZodNumber: () => ZodNumber,
11940
+ ZodObject: () => ZodObject,
11941
+ ZodOptional: () => ZodOptional,
11942
+ ZodParsedType: () => ZodParsedType,
11943
+ ZodPipeline: () => ZodPipeline,
11944
+ ZodPromise: () => ZodPromise,
11945
+ ZodReadonly: () => ZodReadonly,
11946
+ ZodRecord: () => ZodRecord,
11947
+ ZodSchema: () => ZodType,
11948
+ ZodSet: () => ZodSet,
11949
+ ZodString: () => ZodString,
11950
+ ZodSymbol: () => ZodSymbol,
11951
+ ZodTransformer: () => ZodEffects,
11952
+ ZodTuple: () => ZodTuple,
11953
+ ZodType: () => ZodType,
11954
+ ZodUndefined: () => ZodUndefined,
11955
+ ZodUnion: () => ZodUnion,
11956
+ ZodUnknown: () => ZodUnknown,
11957
+ ZodVoid: () => ZodVoid,
11958
+ addIssueToContext: () => addIssueToContext,
11959
+ any: () => anyType,
11960
+ array: () => arrayType,
11961
+ bigint: () => bigIntType,
11962
+ boolean: () => booleanType,
11963
+ coerce: () => coerce,
11964
+ custom: () => custom,
11965
+ date: () => dateType,
11966
+ datetimeRegex: () => datetimeRegex,
11967
+ defaultErrorMap: () => en_default,
11968
+ discriminatedUnion: () => discriminatedUnionType,
11969
+ effect: () => effectsType,
11970
+ enum: () => enumType,
11971
+ function: () => functionType,
11972
+ getErrorMap: () => getErrorMap,
11973
+ getParsedType: () => getParsedType,
11974
+ instanceof: () => instanceOfType,
11975
+ intersection: () => intersectionType,
11976
+ isAborted: () => isAborted,
11977
+ isAsync: () => isAsync,
11978
+ isDirty: () => isDirty,
11979
+ isValid: () => isValid,
11980
+ late: () => late,
11981
+ lazy: () => lazyType,
11982
+ literal: () => literalType,
11983
+ makeIssue: () => makeIssue,
11984
+ map: () => mapType,
11985
+ nan: () => nanType,
11986
+ nativeEnum: () => nativeEnumType,
11987
+ never: () => neverType,
11988
+ null: () => nullType,
11989
+ nullable: () => nullableType,
11990
+ number: () => numberType,
11991
+ object: () => objectType,
11992
+ objectUtil: () => objectUtil,
11993
+ oboolean: () => oboolean,
11994
+ onumber: () => onumber,
11995
+ optional: () => optionalType,
11996
+ ostring: () => ostring,
11997
+ pipeline: () => pipelineType,
11998
+ preprocess: () => preprocessType,
11999
+ promise: () => promiseType,
12000
+ quotelessJson: () => quotelessJson,
12001
+ record: () => recordType,
12002
+ set: () => setType,
12003
+ setErrorMap: () => setErrorMap,
12004
+ strictObject: () => strictObjectType,
12005
+ string: () => stringType,
12006
+ symbol: () => symbolType,
12007
+ transformer: () => effectsType,
12008
+ tuple: () => tupleType,
12009
+ undefined: () => undefinedType,
12010
+ union: () => unionType,
12011
+ unknown: () => unknownType,
12012
+ util: () => util,
12013
+ void: () => voidType
12012
12014
  });
12013
12015
 
12014
12016
  // node_modules/zod/v3/helpers/util.js
@@ -15935,55 +15937,55 @@ function config(newConfig) {
15935
15937
  // node_modules/zod/v4/core/util.js
15936
15938
  var exports_util = {};
15937
15939
  __export(exports_util, {
15938
- unwrapMessage: () => unwrapMessage,
15939
- stringifyPrimitive: () => stringifyPrimitive,
15940
- required: () => required,
15941
- randomString: () => randomString,
15942
- propertyKeyTypes: () => propertyKeyTypes,
15943
- promiseAllObject: () => promiseAllObject,
15944
- primitiveTypes: () => primitiveTypes,
15945
- prefixIssues: () => prefixIssues,
15946
- pick: () => pick,
15947
- partial: () => partial,
15948
- optionalKeys: () => optionalKeys,
15949
- omit: () => omit,
15950
- numKeys: () => numKeys,
15951
- nullish: () => nullish,
15952
- normalizeParams: () => normalizeParams,
15953
- merge: () => merge,
15954
- jsonStringifyReplacer: () => jsonStringifyReplacer,
15955
- joinValues: () => joinValues,
15956
- issue: () => issue,
15957
- isPlainObject: () => isPlainObject,
15958
- isObject: () => isObject,
15959
- getSizableOrigin: () => getSizableOrigin,
15960
- getParsedType: () => getParsedType2,
15961
- getLengthableOrigin: () => getLengthableOrigin,
15962
- getEnumValues: () => getEnumValues,
15963
- getElementAtPath: () => getElementAtPath,
15964
- floatSafeRemainder: () => floatSafeRemainder2,
15965
- finalizeIssue: () => finalizeIssue,
15966
- extend: () => extend,
15967
- escapeRegex: () => escapeRegex,
15968
- esc: () => esc,
15969
- defineLazy: () => defineLazy,
15970
- createTransparentProxy: () => createTransparentProxy,
15971
- clone: () => clone,
15972
- cleanRegex: () => cleanRegex,
15973
- cleanEnum: () => cleanEnum,
15974
- captureStackTrace: () => captureStackTrace,
15975
- cached: () => cached,
15976
- assignProp: () => assignProp,
15977
- assertNotEqual: () => assertNotEqual,
15978
- assertNever: () => assertNever,
15979
- assertIs: () => assertIs,
15980
- assertEqual: () => assertEqual,
15981
- assert: () => assert,
15982
- allowsEval: () => allowsEval,
15983
- aborted: () => aborted,
15984
- NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
15940
+ BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
15985
15941
  Class: () => Class,
15986
- BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES
15942
+ NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
15943
+ aborted: () => aborted,
15944
+ allowsEval: () => allowsEval,
15945
+ assert: () => assert,
15946
+ assertEqual: () => assertEqual,
15947
+ assertIs: () => assertIs,
15948
+ assertNever: () => assertNever,
15949
+ assertNotEqual: () => assertNotEqual,
15950
+ assignProp: () => assignProp,
15951
+ cached: () => cached,
15952
+ captureStackTrace: () => captureStackTrace,
15953
+ cleanEnum: () => cleanEnum,
15954
+ cleanRegex: () => cleanRegex,
15955
+ clone: () => clone,
15956
+ createTransparentProxy: () => createTransparentProxy,
15957
+ defineLazy: () => defineLazy,
15958
+ esc: () => esc,
15959
+ escapeRegex: () => escapeRegex,
15960
+ extend: () => extend,
15961
+ finalizeIssue: () => finalizeIssue,
15962
+ floatSafeRemainder: () => floatSafeRemainder2,
15963
+ getElementAtPath: () => getElementAtPath,
15964
+ getEnumValues: () => getEnumValues,
15965
+ getLengthableOrigin: () => getLengthableOrigin,
15966
+ getParsedType: () => getParsedType2,
15967
+ getSizableOrigin: () => getSizableOrigin,
15968
+ isObject: () => isObject,
15969
+ isPlainObject: () => isPlainObject,
15970
+ issue: () => issue,
15971
+ joinValues: () => joinValues,
15972
+ jsonStringifyReplacer: () => jsonStringifyReplacer,
15973
+ merge: () => merge,
15974
+ normalizeParams: () => normalizeParams,
15975
+ nullish: () => nullish,
15976
+ numKeys: () => numKeys,
15977
+ omit: () => omit,
15978
+ optionalKeys: () => optionalKeys,
15979
+ partial: () => partial,
15980
+ pick: () => pick,
15981
+ prefixIssues: () => prefixIssues,
15982
+ primitiveTypes: () => primitiveTypes,
15983
+ promiseAllObject: () => promiseAllObject,
15984
+ propertyKeyTypes: () => propertyKeyTypes,
15985
+ randomString: () => randomString,
15986
+ required: () => required,
15987
+ stringifyPrimitive: () => stringifyPrimitive,
15988
+ unwrapMessage: () => unwrapMessage
15987
15989
  });
15988
15990
  function assertEqual(val) {
15989
15991
  return val;
@@ -19831,14 +19833,14 @@ function getLiteralValue(schema) {
19831
19833
  // node_modules/zod/v4/classic/iso.js
19832
19834
  var exports_iso2 = {};
19833
19835
  __export(exports_iso2, {
19834
- time: () => time2,
19835
- duration: () => duration2,
19836
- datetime: () => datetime2,
19837
- date: () => date2,
19838
- ZodISOTime: () => ZodISOTime,
19839
- ZodISODuration: () => ZodISODuration,
19836
+ ZodISODate: () => ZodISODate,
19840
19837
  ZodISODateTime: () => ZodISODateTime,
19841
- ZodISODate: () => ZodISODate
19838
+ ZodISODuration: () => ZodISODuration,
19839
+ ZodISOTime: () => ZodISOTime,
19840
+ date: () => date2,
19841
+ datetime: () => datetime2,
19842
+ duration: () => duration2,
19843
+ time: () => time2
19842
19844
  });
19843
19845
  var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
19844
19846
  $ZodISODateTime.init(inst, def);
@@ -25414,6 +25416,7 @@ var Kinds = [
25414
25416
  "preferences",
25415
25417
  "responsibilities",
25416
25418
  "protocols",
25419
+ "selfcorrection",
25417
25420
  "diary",
25418
25421
  "session",
25419
25422
  "thread",
@@ -25431,6 +25434,7 @@ var KIND_AREA = {
25431
25434
  preferences: "master",
25432
25435
  responsibilities: "llm",
25433
25436
  protocols: "llm",
25437
+ selfcorrection: "llm",
25434
25438
  diary: "llm",
25435
25439
  session: "memory",
25436
25440
  thread: "memory",
@@ -25447,7 +25451,8 @@ var SingletonKinds = [
25447
25451
  "goals",
25448
25452
  "preferences",
25449
25453
  "responsibilities",
25450
- "protocols"
25454
+ "protocols",
25455
+ "selfcorrection"
25451
25456
  ];
25452
25457
  var Statuses = ["active", "resolved", "superseded", "dormant", "eternal"];
25453
25458
  var RelationTypes = [
@@ -25970,10 +25975,10 @@ class TriliumClient {
25970
25975
  import { existsSync, readFileSync, writeFileSync } from "fs";
25971
25976
  import { join, dirname } from "path";
25972
25977
  var EMPTY_BRAINLLM = {
25973
- version: 9,
25978
+ version: 10,
25974
25979
  root: "",
25975
25980
  master: { root: "", biography: "", goals: "", preferences: "" },
25976
- llm: { root: "", responsibilities: "", protocols: "", diary: "" },
25981
+ llm: { root: "", responsibilities: "", protocols: "", selfcorrection: "", diary: "" },
25977
25982
  memory: { root: "", sessions: "", threads: "", metaThread: "" },
25978
25983
  knowledge: { root: "", master: "", domains: "" },
25979
25984
  insights: { root: "", logs: "" },
@@ -26014,9 +26019,10 @@ function loadConfig() {
26014
26019
  return null;
26015
26020
  try {
26016
26021
  const parsed = JSON.parse(readFileSync(path, "utf-8"));
26017
- if (typeof parsed?.root === "string" && (parsed?.version === 9 || parsed?.version === 8 || parsed?.version === 5)) {
26022
+ if (typeof parsed?.root === "string" && [10, 9, 8, 5].includes(parsed?.version)) {
26018
26023
  return {
26019
26024
  ...parsed,
26025
+ llm: { selfcorrection: "", ...parsed.llm ?? {} },
26020
26026
  memory: { metaThread: "", ...parsed.memory ?? {} },
26021
26027
  policy: { ...DEFAULT_POLICY, ...parsed.policy ?? {} }
26022
26028
  };
@@ -26026,7 +26032,7 @@ function loadConfig() {
26026
26032
  }
26027
26033
  function saveConfig(config2) {
26028
26034
  const path = configFilePath();
26029
- writeFileSync(path, JSON.stringify({ ...config2, version: 9 }, null, 2) + `
26035
+ writeFileSync(path, JSON.stringify({ ...config2, version: 10 }, null, 2) + `
26030
26036
  `, "utf-8");
26031
26037
  return path;
26032
26038
  }
@@ -26060,7 +26066,7 @@ async function discoverBrainLLM(trilium) {
26060
26066
  config2.master = { root: id, biography: g("Biography"), goals: g("Goals"), preferences: g("Preferences") };
26061
26067
  break;
26062
26068
  case "LLM":
26063
- config2.llm = { root: id, responsibilities: g("Responsibilities"), protocols: g("Protocols"), diary: g("Diary") };
26069
+ config2.llm = { root: id, responsibilities: g("Responsibilities"), protocols: g("Protocols"), selfcorrection: g("Self-correction"), diary: g("Diary") };
26064
26070
  break;
26065
26071
  case "Memory":
26066
26072
  config2.memory = { root: id, sessions: g("Sessions"), threads: g("Threads"), metaThread: "" };
@@ -26187,8 +26193,55 @@ function decodeEncodedHtml(body) {
26187
26193
  s = decodeEntitiesOnce(s);
26188
26194
  return s.replace(/&(?![a-zA-Z]+;|#\d+;|#x[0-9a-fA-F]+;)/g, "&");
26189
26195
  }
26196
+ var DOUBLE_ESCAPE = /&((?:[a-zA-Z][a-zA-Z0-9]*|#\d+|#x[0-9a-fA-F]+);)/g;
26197
+ var CODE_SPAN = /<(?:code|pre)[\s\S]*?<\/(?:code|pre)>/gi;
26190
26198
  function repairDoubleEscaping(html) {
26191
- return html.replace(/&amp;((?:[a-zA-Z][a-zA-Z0-9]*|#\d+|#x[0-9a-fA-F]+);)/g, (_, entity) => `&${entity}`);
26199
+ const parts = [];
26200
+ let last = 0;
26201
+ for (const m of html.matchAll(CODE_SPAN)) {
26202
+ const start = m.index ?? 0;
26203
+ parts.push(html.slice(last, start).replace(DOUBLE_ESCAPE, (_, entity) => `&${entity}`), m[0]);
26204
+ last = start + m[0].length;
26205
+ }
26206
+ parts.push(html.slice(last).replace(DOUBLE_ESCAPE, (_, entity) => `&${entity}`));
26207
+ return parts.join("");
26208
+ }
26209
+ function classifyDoubleEscape(html) {
26210
+ if (!DOUBLE_ESCAPE.test(html))
26211
+ return "clean";
26212
+ DOUBLE_ESCAPE.lastIndex = 0;
26213
+ const outside = html.replace(CODE_SPAN, "");
26214
+ DOUBLE_ESCAPE.lastIndex = 0;
26215
+ return DOUBLE_ESCAPE.test(outside) ? "carries" : "documents";
26216
+ }
26217
+ var ADDENDUM_MARKER = /<h[2-4][^>]*>\s*Addendum\s*(?:\u2014|\u2013|-|&mdash;|&ndash;)/i;
26218
+ function hasAddendumMarker(html) {
26219
+ return ADDENDUM_MARKER.test(html);
26220
+ }
26221
+ function editDistance(a, b) {
26222
+ const m = a.length, n = b.length;
26223
+ if (!m)
26224
+ return n;
26225
+ if (!n)
26226
+ return m;
26227
+ let prev = Array.from({ length: n + 1 }, (_, j) => j);
26228
+ for (let i = 1;i <= m; i++) {
26229
+ const cur = [i];
26230
+ for (let j = 1;j <= n; j++) {
26231
+ cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1].toLowerCase() === b[j - 1].toLowerCase() ? 0 : 1));
26232
+ }
26233
+ prev = cur;
26234
+ }
26235
+ return prev[n];
26236
+ }
26237
+ function nearestHeading(requested, available) {
26238
+ let best = null;
26239
+ for (const heading of available) {
26240
+ const distance = editDistance(requested, heading);
26241
+ if (!best || distance < best.distance)
26242
+ best = { heading, distance };
26243
+ }
26244
+ return best;
26192
26245
  }
26193
26246
  function inlineMd(escaped) {
26194
26247
  return escaped.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/(^|[\s(])\*([^*\s][^*]*)\*/g, "$1<em>$2</em>").replace(/`([^`]+)`/g, "<code>$1</code>").replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, '<a href="$2">$1</a>');
@@ -26707,8 +26760,9 @@ function setSection(html, heading, content, mode, occurrence = 1) {
26707
26760
  ${html.slice(headingStart)}`, matched: true, headingCount };
26708
26761
  }
26709
26762
  if (mode === "after") {
26710
- return { html: `${html.slice(0, contentStart)}
26711
- ${content}${html.slice(contentStart)}`, matched: true, headingCount };
26763
+ return { html: `${html.slice(0, end).replace(/\s*$/, "")}
26764
+ ${content}
26765
+ ${html.slice(end)}`, matched: true, headingCount };
26712
26766
  }
26713
26767
  const existing = html.slice(contentStart, end).trim();
26714
26768
  const inner = mode === "append" && existing ? `${existing}
@@ -26958,7 +27012,8 @@ var STRUCTURED_SINGLETONS = new Set([
26958
27012
  "goals",
26959
27013
  "preferences",
26960
27014
  "responsibilities",
26961
- "protocols"
27015
+ "protocols",
27016
+ "selfcorrection"
26962
27017
  ]);
26963
27018
  var hasHeading = (html, text) => new RegExp(`<h[2-4](?:\\s[^>]*)?>\\s*${text}\\s*</h[2-4]>`, "i").test(html);
26964
27019
  var REQUIRED_SECTIONS = {
@@ -27014,8 +27069,10 @@ ${o.goal ? `<p>${escapeHtml(o.goal)}</p>` : o.body || "<p>To be determined.</p>"
27014
27069
  <p></p>`].join(`
27015
27070
  `);
27016
27071
  case "protocols":
27017
- return ["<h2>Operating</h2>", o.body || "<p></p>", `<h2>Self-correction</h2>
27018
- <p></p>`].join(`
27072
+ return ["<h2>Operating</h2>", o.body || "<p></p>"].join(`
27073
+ `);
27074
+ case "selfcorrection":
27075
+ return ["<h2>Corrections</h2>", o.body || "<p></p>"].join(`
27019
27076
  `);
27020
27077
  case "domain":
27021
27078
  return domainContent(o.domain ?? "");
@@ -27200,6 +27257,8 @@ function kindHome(cfg, kind) {
27200
27257
  return cfg.llm.responsibilities;
27201
27258
  case "protocols":
27202
27259
  return cfg.llm.protocols;
27260
+ case "selfcorrection":
27261
+ return cfg.llm.selfcorrection;
27203
27262
  case "diary":
27204
27263
  return cfg.llm.diary;
27205
27264
  case "session":
@@ -27314,6 +27373,8 @@ function locationLabel(kind, domainTitle) {
27314
27373
  return "LLM \u2192 Responsibilities";
27315
27374
  case "protocols":
27316
27375
  return "LLM \u2192 Protocols";
27376
+ case "selfcorrection":
27377
+ return "LLM \u2192 Self-correction";
27317
27378
  case "diary":
27318
27379
  return "LLM \u2192 Diary";
27319
27380
  case "session":
@@ -27348,6 +27409,7 @@ function structuralIds(cfg) {
27348
27409
  cfg.llm.root,
27349
27410
  cfg.llm.responsibilities,
27350
27411
  cfg.llm.protocols,
27412
+ cfg.llm.selfcorrection,
27351
27413
  cfg.llm.diary,
27352
27414
  cfg.memory.root,
27353
27415
  cfg.memory.sessions,
@@ -27368,7 +27430,8 @@ function isContainer(cfg, noteId) {
27368
27430
  cfg.master.goals,
27369
27431
  cfg.master.preferences,
27370
27432
  cfg.llm.responsibilities,
27371
- cfg.llm.protocols
27433
+ cfg.llm.protocols,
27434
+ cfg.llm.selfcorrection
27372
27435
  ];
27373
27436
  return isStructural(cfg, noteId) && !singletons.includes(noteId);
27374
27437
  }
@@ -27711,6 +27774,8 @@ async function sweep(trilium, cfg, opts = {}) {
27711
27774
  if (reported.has(pairKey))
27712
27775
  continue;
27713
27776
  reported.add(pairKey);
27777
+ if (acknowledged(a) || acknowledged(bn))
27778
+ continue;
27714
27779
  const [ha, hb] = await Promise.all([headingsOf(a), headingsOf(bn)]);
27715
27780
  const overlap = ha.filter((h) => hb.some((x) => x.toLowerCase() === h.toLowerCase()));
27716
27781
  const show = (h) => h.length ? h.slice(0, 8).join(" \xB7 ") + (h.length > 8 ? " \xB7 \u2026" : "") : "(no headings)";
@@ -27749,10 +27814,17 @@ async function hygienePasses(trilium, cfg, report, ctx) {
27749
27814
  for (const n of corrupted) {
27750
27815
  if (!eligible(n))
27751
27816
  continue;
27817
+ const content = await trilium.getNoteContent(n.noteId).catch(() => "");
27818
+ const verdict = classifyDoubleEscape(content);
27819
+ if (verdict !== "carries") {
27820
+ if (ctx.repair.has(n.noteId)) {
27821
+ report.flagged.push(`entity-corrupted: ${n.title} [${n.noteId}] \u2014 repair requested but the only matches live inside code spans: the note DOCUMENTS the signature rather than carrying it, and was left untouched. maintain(ack=["${n.noteId}"]) to silence.`);
27822
+ }
27823
+ continue;
27824
+ }
27752
27825
  if (ctx.repair.has(n.noteId)) {
27753
- const before = await trilium.getNoteContent(n.noteId).catch(() => "");
27754
- const after = repairDoubleEscaping(before);
27755
- if (after === before) {
27826
+ const after = repairDoubleEscaping(content);
27827
+ if (after === content) {
27756
27828
  report.flagged.push(`entity-corrupted: ${n.title} [${n.noteId}] \u2014 repair requested but the body did not change; the match is a note DOCUMENTING the signature rather than carrying it. maintain(ack=["${n.noteId}"]) to silence.`);
27757
27829
  continue;
27758
27830
  }
@@ -27781,6 +27853,18 @@ async function hygienePasses(trilium, cfg, report, ctx) {
27781
27853
  if (due) {
27782
27854
  report.flagged.push(`claim ${verifiedOn ? "lapsed" : "unverified"}: "${n.title}" [${n.noteId}] \u2014 ` + `${verifiedOn ? `last verified ${verifiedOn}, interval ${interval}d` : "never verified since registration"}. ` + `Read its check with claim(claimId="${n.noteId}"), run it, and record the result.`);
27783
27855
  }
27856
+ if (verifiedOn) {
27857
+ const sources = n.attributes.filter((a) => a.type === "relation" && a.name === "derivedFrom");
27858
+ for (const rel of sources) {
27859
+ const src = await trilium.getNote(rel.value).catch(() => null);
27860
+ if (!src)
27861
+ continue;
27862
+ const srcDay = src.dateModified.slice(0, 10);
27863
+ if (srcDay > verifiedOn) {
27864
+ report.flagged.push(`claim source-changed: "${n.title}" [${n.noteId}] \u2014 its ~derivedFrom source "${src.title}" [${src.noteId}] was revised on ${srcDay}, after the last verification on ${verifiedOn}. ` + `The check no longer covers what the note now says \u2014 re-verify with claim(claimId="${n.noteId}", holds=\u2026, evidence=\u2026) or retire it.`);
27865
+ }
27866
+ }
27867
+ }
27784
27868
  }
27785
27869
  const titled = await ctx.connectable("#noteType", 300);
27786
27870
  const RECORD_TITLES = new Set(["diary", "session", "log", "threadEntry"]);
@@ -27864,7 +27948,8 @@ async function buildDigest(trilium, cfg, opts = {}) {
27864
27948
  ]),
27865
27949
  Promise.all([
27866
27950
  readSlot("responsibilities", cfg.llm.responsibilities),
27867
- readSlot("protocols", cfg.llm.protocols)
27951
+ readSlot("protocols", cfg.llm.protocols),
27952
+ readSlot("selfcorrection", cfg.llm.selfcorrection)
27868
27953
  ])
27869
27954
  ]);
27870
27955
  digest.master.push(...masterSlots.filter((s) => !!s));
@@ -27974,9 +28059,10 @@ async function createBrainLLMStructure(trilium) {
27974
28059
  leaf(masterRoot, "Preferences", "preferences", "A single maintained note of the master/user's preferences.")
27975
28060
  ]);
27976
28061
  const llmRoot = await book(rootId, "LLM", CONTAINER_PURPOSES.llm, "bx bx-bot");
27977
- const [responsibilities, protocols, diary] = await Promise.all([
28062
+ const [responsibilities, protocols, selfcorrection, diary] = await Promise.all([
27978
28063
  leaf(llmRoot, "Responsibilities", "responsibilities", "A single maintained note of the assistant's responsibilities to the master/user, derived from their goals and preferences."),
27979
28064
  leaf(llmRoot, "Protocols", "protocols", "A single maintained note of the assistant's operating and self-correctness protocols \u2014 how it maximises its value to the master/user by efficiently meeting its responsibilities."),
28065
+ leaf(llmRoot, "Self-correction", "selfcorrection", "A single maintained note of the assistant's own corrections \u2014 the mistakes it has made, what generalises from each, and the rule that prevents a repeat. Split out of Protocols in V12 so orientation stops paying for it on every session start."),
27980
28066
  book(llmRoot, "Diary", CONTAINER_PURPOSES.llmDiary, "bx bx-book-heart")
27981
28067
  ]);
27982
28068
  const memoryRoot = await book(rootId, "Memory", CONTAINER_PURPOSES.memory, "bx bx-been-here");
@@ -27992,10 +28078,10 @@ async function createBrainLLMStructure(trilium) {
27992
28078
  const insightsRoot = await book(rootId, "Insights", CONTAINER_PURPOSES.insights, "bx bx-bulb");
27993
28079
  const logs = await book(insightsRoot, "Logs", CONTAINER_PURPOSES.insightsLogs, "bx bx-history");
27994
28080
  return {
27995
- version: 9,
28081
+ version: 10,
27996
28082
  root: rootId,
27997
28083
  master: { root: masterRoot, biography, goals, preferences },
27998
- llm: { root: llmRoot, responsibilities, protocols, diary },
28084
+ llm: { root: llmRoot, responsibilities, protocols, selfcorrection, diary },
27999
28085
  memory: { root: memoryRoot, sessions, threads, metaThread: "" },
28000
28086
  knowledge: { root: knowledgeRoot, master: knowledgeMaster, domains },
28001
28087
  insights: { root: insightsRoot, logs },
@@ -28166,12 +28252,19 @@ day's blocks rather than the whole week. outline(id) lists the headings.`, {
28166
28252
  // src/tools-llm.ts
28167
28253
  function registerLlmTools(server, trilium, brainRef) {
28168
28254
  const b = () => brainRef.config;
28169
- server.tool("llm", `Read an LLM note: responsibilities or protocols (singletons), or a diary entry by id.
28255
+ server.tool("llm", `Read an LLM note: responsibilities, protocols or selfcorrection (singletons), or a diary
28256
+ entry by id.
28257
+
28258
+ selfcorrection holds the assistant's own corrections \u2014 what it got wrong, what generalises, and
28259
+ the rule that prevents a repeat. It is the one LLM singleton start() does NOT serve in full: it
28260
+ is the largest and the least load-bearing at a first message, so it arrives as section headings
28261
+ and is read here on demand. Reach for it when about to repeat a class of work that has gone
28262
+ wrong before \u2014 an audit, a large edit, a claim of completeness.
28170
28263
 
28171
28264
  section="<heading>" reads ONE section instead of the whole note \u2014 the efficient path on
28172
- protocols, which is the largest singleton and the one most often needed in part rather than
28173
- whole. outline(id) lists the headings.`, {
28174
- which: exports_external.enum(["responsibilities", "protocols", "diary"]),
28265
+ protocols and selfcorrection, the two largest singletons and the ones most often needed in part
28266
+ rather than whole. outline(id) lists the headings.`, {
28267
+ which: exports_external.enum(["responsibilities", "protocols", "selfcorrection", "diary"]),
28175
28268
  id: exports_external.string().optional().describe("diary only: the entry id from llm_recall"),
28176
28269
  section: exports_external.string().optional().describe("Read only this heading's section (h2/h3/h4), instead of the whole note"),
28177
28270
  occurrence: exports_external.number().int().positive().optional().describe("section=: which same-text heading, 1-based (default: the first)")
@@ -28182,20 +28275,23 @@ whole. outline(id) lists the headings.`, {
28182
28275
  return txt(await readFull(trilium, id, { section, occurrence }));
28183
28276
  }
28184
28277
  const noteId = b().llm[which];
28185
- if (!noteId)
28186
- throw new Error("BrainLLM not bootstrapped \u2014 run bootstrap.");
28278
+ if (!noteId) {
28279
+ throw new Error(which === "selfcorrection" ? "This brain has no Self-correction note yet \u2014 it arrived in V12. Run bootstrap() once; it finds or creates the note and persists its id, leaving everything else untouched." : "BrainLLM not bootstrapped \u2014 run bootstrap.");
28280
+ }
28187
28281
  return txt(await readFull(trilium, noteId, { section, occurrence }));
28188
28282
  });
28189
- server.tool("llm_recall", "Skim the LLM surface: responsibilities & protocols opening lines (with relation snippets), plus recent diary entries.", { limit: exports_external.number().optional() }, async ({ limit }) => {
28283
+ server.tool("llm_recall", "Skim the LLM surface: responsibilities, protocols & self-correction opening lines (with relation snippets), plus recent diary entries.", { limit: exports_external.number().optional() }, async ({ limit }) => {
28190
28284
  const cfg = b();
28191
- const [resp, prot, diary] = await Promise.all([
28285
+ const [resp, prot, selfcorr, diary] = await Promise.all([
28192
28286
  previewWithRelations(trilium, cfg.llm.responsibilities),
28193
28287
  previewWithRelations(trilium, cfg.llm.protocols),
28288
+ cfg.llm.selfcorrection ? previewWithRelations(trilium, cfg.llm.selfcorrection) : Promise.resolve(null),
28194
28289
  skim(trilium, cfg.llm.diary, { kind: "diary", limit: limit ?? 7 })
28195
28290
  ]);
28196
28291
  return txt({
28197
28292
  responsibilities: { id: cfg.llm.responsibilities, ...resp },
28198
28293
  protocols: { id: cfg.llm.protocols, ...prot },
28294
+ ...selfcorr ? { selfcorrection: { id: cfg.llm.selfcorrection, ...selfcorr } } : {},
28199
28295
  diary
28200
28296
  });
28201
28297
  });
@@ -28660,10 +28756,14 @@ rather than listing them unconditionally for every caller to work around.`, {
28660
28756
  }
28661
28757
  }
28662
28758
  const hygiene = await sweep(trilium, cfg, { deep: false, dryRun: false }).catch(() => null);
28663
- const pendingAddendums = await trilium.searchNotes("#noteType note.content *=* 'Addendum'", { ancestorNoteId: cfg.root, fastSearch: false, limit: 40 }).then((r) => r.results.filter((n) => {
28664
- const kind = labelOf2(n, "noteType");
28665
- return kind && !["session", "diary", "log", "threadEntry", "thread"].includes(kind);
28666
- }).length).catch(() => null);
28759
+ const pendingAddendums = await trilium.searchNotes("#noteType note.content *=* 'Addendum'", { ancestorNoteId: cfg.root, fastSearch: false, limit: 40 }).then(async (r) => {
28760
+ const candidates = r.results.filter((n) => {
28761
+ const kind = labelOf2(n, "noteType");
28762
+ return kind && !["session", "diary", "log", "threadEntry", "thread"].includes(kind);
28763
+ });
28764
+ const contents = await Promise.all(candidates.map((n) => trilium.getNoteContent(n.noteId).catch(() => "")));
28765
+ return contents.filter(hasAddendumMarker).length;
28766
+ }).catch(() => null);
28667
28767
  const singletonStubs = [
28668
28768
  ["biography", biography],
28669
28769
  ["goals", goals],
@@ -29504,13 +29604,17 @@ applies several surgeries in one call, in order, against one read and one write.
29504
29604
 
29505
29605
  Granularity warning: section + mode=replace swaps the ENTIRE section body \u2014 everything under
29506
29606
  that heading, not one paragraph within it. To change a single paragraph inside a section, use
29507
- find=; to add content next to a heading without touching its body, use mode="before"/"after".`, {
29607
+ find=; to add a sibling block around a whole section without touching its body, use
29608
+ mode="before"/"after". Both are section-relative: "after" lands past the end of that section's
29609
+ body, so inserting a heading with it creates a NEW section rather than nesting one under the
29610
+ target \u2014 which is what it used to do, emptying the target while reporting matched: true.`, {
29508
29611
  noteId: exports_external.string().describe("Note to update"),
29509
29612
  body: exports_external.string().optional().describe("Content to add/replace: plain text, markdown, or HTML. With find=, the raw replacement string (no conversion)."),
29510
29613
  title: exports_external.string().optional().describe("New title (normalized server-side)"),
29511
29614
  section: exports_external.string().optional().describe("Target a section by heading text (h2/h3/h4, in that order); omit for whole-note append/replace"),
29512
29615
  occurrence: exports_external.number().int().positive().optional().describe("section=: which same-text heading to target, 1-based (default: the first). Read them with outline(noteId)."),
29513
- mode: exports_external.enum(["append", "replace", "before", "after", "remove"]).optional().describe('append (default) | replace | before | after | remove \u2014 "before"/"after" insert adjacent to the section= heading without touching its body; "remove" deletes the section= heading and its body, and needs no body='),
29616
+ strict: exports_external.boolean().optional().describe("section=: refuse instead of writing when no heading matches. The default writes the content as a NEW section on a miss \u2014 right for a genuinely new heading, wrong for a typo. With strict=true a miss returns available= and a didYouMean suggestion, and the note is untouched."),
29617
+ mode: exports_external.enum(["append", "replace", "before", "after", "remove"]).optional().describe('append (default) | replace | before | after | remove \u2014 "before"/"after" insert a sibling block around the WHOLE section= section (before its heading, or after the last of its body) without touching that body, so inserting a heading with "after" creates a new section rather than nesting one under the target; "remove" deletes the section= heading and its body, and needs no body='),
29514
29618
  find: exports_external.string().optional().describe("Exact raw string to replace throughout the body with body= \u2014 targeted surgery without a read+full-replace. Takes precedence over section/mode."),
29515
29619
  nth: exports_external.number().int().positive().optional().describe("find=: replace only the Nth occurrence, 1-based (default: all of them)"),
29516
29620
  edits: exports_external.array(exports_external.object({
@@ -29521,7 +29625,7 @@ find=; to add content next to a heading without touching its body, use mode="bef
29521
29625
  identity: exports_external.string().optional().describe(`append mode: the addendum's identification line \u2014 "LLM \xB7 environment \xB7 agent/mode [\xB7 Run N]"; REQUIRED when appending to a thread (unless the body already leads with the h3)`),
29522
29626
  icon: exports_external.string().optional().describe('Display icon \u2014 a boxicons class ("bx bx-brain") or a bare name; normalized server-side'),
29523
29627
  date: exports_external.string().optional().describe("ISO date (default: today)")
29524
- }, async ({ noteId, body, title, section, occurrence, mode, find, nth, edits, identity, icon, date: date4 }) => {
29628
+ }, async ({ noteId, body, title, section, occurrence, mode, find, nth, edits, identity, icon, date: date4, strict }) => {
29525
29629
  if (isContainer(b(), noteId))
29526
29630
  return err("protected_note", `Note ${noteId} is a container \u2014 its content cannot be edited directly.`, "Use remember() to write to singletons, or specify a content note id.");
29527
29631
  const d = date4 ?? today();
@@ -29728,9 +29832,14 @@ find=; to add content next to a heading without touching its body, use mode="bef
29728
29832
  }
29729
29833
  const current = await trilium.getNoteContent(noteId).catch(() => "");
29730
29834
  if (section) {
29731
- await trilium.createRevision(noteId).catch(() => null);
29732
29835
  const sectionMode = mode === "append" || mode === "before" || mode === "after" ? mode : "replace";
29733
29836
  const result = setSection(current, section, html, sectionMode, occurrence ?? 1);
29837
+ const near = !result.matched && result.available?.length ? nearestHeading(section, result.available) : null;
29838
+ const suggestion = near && near.distance <= Math.max(2, Math.floor(section.length / 5)) ? near : null;
29839
+ if (strict && !result.matched) {
29840
+ return err("section_not_found", `strict=true: no heading matches "${section}" and nothing was written.`, `Available headings: ${result.available?.length ? result.available.join(" \xB7 ") : "(none)"}${suggestion ? ` \u2014 did you mean "${suggestion.heading}"?` : ""} Re-target with the exact text, or drop strict= to allow the new-section append.`);
29841
+ }
29842
+ await trilium.createRevision(noteId).catch(() => null);
29734
29843
  finalContent = bumpLastUpdated(result.html, d).html;
29735
29844
  await trilium.updateNoteContent(noteId, finalContent);
29736
29845
  sectionResult = {
@@ -29740,7 +29849,8 @@ find=; to add content next to a heading without touching its body, use mode="bef
29740
29849
  };
29741
29850
  sectionMiss = {
29742
29851
  ...result.appendedAtLevel ? { appendedAtLevel: result.appendedAtLevel } : {},
29743
- ...result.available?.length ? { available: result.available } : {}
29852
+ ...result.available?.length ? { available: result.available } : {},
29853
+ ...suggestion ? { didYouMean: suggestion.heading } : {}
29744
29854
  };
29745
29855
  } else if (mode === "replace") {
29746
29856
  await trilium.createRevision(noteId).catch(() => null);
@@ -29775,7 +29885,7 @@ ${block}`), d).html;
29775
29885
  const relations = relationSnippet(note);
29776
29886
  const targeted = occurrence && occurrence > 1 ? ` occurrence ${occurrence} of` : "";
29777
29887
  const verb = mode === "append" ? "appended to" : mode === "before" || mode === "after" ? `inserted ${mode}` : "replaced";
29778
- const sectionHint = !sectionResult ? undefined : !sectionResult.matched ? `No existing "${section}" heading found at h2/h3/h4 \u2014 wrote a NEW h${sectionMiss.appendedAtLevel ?? 2} section instead of replacing anything. Check available= for the note's real heading texts, then re-target.` : sectionResult.headingCount > 1 && !occurrence ? `${sectionResult.headingCount} headings match "${section}" \u2014 the FIRST was ${verb}. Pass occurrence= (1-${sectionResult.headingCount}) to reach a different one; outline(noteId) lists them.` : sectionResult.headingCount > 1 ? `${sectionResult.headingCount} headings match "${section}" \u2014${targeted} that one was ${verb}.` : undefined;
29888
+ const sectionHint = !sectionResult ? undefined : !sectionResult.matched ? `No existing "${section}" heading found at h2/h3/h4 \u2014 wrote a NEW h${sectionMiss.appendedAtLevel ?? 2} section instead of replacing anything.${sectionMiss.didYouMean ? ` Nearest existing heading: "${sectionMiss.didYouMean}" \u2014 a typo is the likeliest cause.` : ""} Check available= for the note's real heading texts, then re-target.` : sectionResult.headingCount > 1 && !occurrence ? `${sectionResult.headingCount} headings match "${section}" \u2014 the FIRST was ${verb}. Pass occurrence= (1-${sectionResult.headingCount}) to reach a different one; outline(noteId) lists them.` : sectionResult.headingCount > 1 ? `${sectionResult.headingCount} headings match "${section}" \u2014${targeted} that one was ${verb}.` : undefined;
29779
29889
  return txt3({
29780
29890
  ok: true,
29781
29891
  noteId,
@@ -30557,13 +30667,12 @@ Returns note IDs, titles, kinds, and content snippets so you can identify what t
30557
30667
  seen.add(n.noteId);
30558
30668
  return true;
30559
30669
  });
30560
- const ADDENDUM_MARKER = /<h[2-4][^>]*>\s*Addendum\s*(?:\u2014|\u2013|-|&mdash;|&ndash;)/i;
30561
30670
  const notes = await Promise.all(unique.map(async (n) => {
30562
30671
  const kind = labelOf2(n, "noteType");
30563
30672
  if (!kind)
30564
30673
  return null;
30565
30674
  const content = await trilium.getNoteContent(n.noteId).catch(() => "");
30566
- if (!ADDENDUM_MARKER.test(content))
30675
+ if (!hasAddendumMarker(content))
30567
30676
  return null;
30568
30677
  const relations = relationSnippet(n);
30569
30678
  return {
@@ -30957,7 +31066,12 @@ exception.`, {
30957
31066
  server.tool("brain", `Surface the entire BrainLLM content tree \u2014 every typed note across all five content areas
30958
31067
  (Master, LLM, Memory, Knowledge, Insights), grouped by area and sub-container, with
30959
31068
  id/title/kind/status/dates. Use to audit what the brain contains or locate a specific note.
30960
- Structural containers are excluded; only content notes appear.`, {
31069
+ Structural containers are excluded; only content notes appear.
31070
+
31071
+ Insights returns { logs, claims }. Claims were missing entirely before V12 \u2014 they live in a
31072
+ container resolved by title rather than named in the config, and this read was scoped one level
31073
+ too deep to reach them, so the register was invisible to the tool that calls itself the full
31074
+ inventory.`, {
30961
31075
  includeArchived: exports_external.boolean().optional().describe("Include archived/resolved notes (default: false)")
30962
31076
  }, async ({ includeArchived }) => {
30963
31077
  const cfg = b();
@@ -31006,10 +31120,12 @@ Structural containers are excluded; only content notes appear.`, {
31006
31120
  fetchFrom(cfg.memory.threads),
31007
31121
  fetchFrom(cfg.knowledge.master),
31008
31122
  fetchFrom(cfg.knowledge.domains),
31009
- fetchFrom(cfg.insights.logs)
31123
+ fetchFrom(cfg.insights.root)
31010
31124
  ]);
31011
31125
  const diaryIds = new Set(llmDiary.map((n) => n.noteId));
31012
31126
  const llmSingletons = llmAll.filter((n) => !diaryIds.has(n.noteId));
31127
+ const insightLogs = insights.filter((n) => labelOf2(n, "noteType") === "log");
31128
+ const insightClaims = insights.filter((n) => labelOf2(n, "noteType") === "claim");
31013
31129
  const areas = {
31014
31130
  Master: masterAll.map(row),
31015
31131
  LLM: {
@@ -31024,7 +31140,10 @@ Structural containers are excluded; only content notes appear.`, {
31024
31140
  master: kMaster.map(row),
31025
31141
  domains: kDomains.map(row)
31026
31142
  },
31027
- Insights: insights.map(row)
31143
+ Insights: {
31144
+ logs: insightLogs.map(row),
31145
+ claims: insightClaims.map(row)
31146
+ }
31028
31147
  };
31029
31148
  const total = masterAll.length + llmSingletons.length + llmDiary.length + sessions.length + threads.length + kMaster.length + kDomains.length + insights.length;
31030
31149
  return txt3({ total, areas });
@@ -31151,9 +31270,10 @@ Pass area= to zoom into one surface and get its full detail.`, {
31151
31270
  ...includeArchived ? {} : { note: "Archived and resolved notes are excluded \u2014 pass includeArchived=true to see them." }
31152
31271
  });
31153
31272
  });
31154
- server.tool("bootstrap", `Initialize the BrainLLM structure in Trilium (idempotent \u2014 safe to re-run; refreshes config
31155
- if the structure already exists). Creates the five areas \u2014 Master (Biography/Goals/Preferences),
31156
- LLM (Responsibilities/Protocols/Diary), Memory (Sessions/Threads), Knowledge (Master/Domains),
31273
+ server.tool("bootstrap", `Initialize the BrainLLM structure in Trilium (idempotent \u2014 safe to re-run; refreshes config,
31274
+ heals singletons a newer version introduced, and re-engraves container purposes if the structure
31275
+ already exists). Creates the five areas \u2014 Master (Biography/Goals/Preferences),
31276
+ LLM (Responsibilities/Protocols/Self-correction/Diary), Memory (Sessions/Threads), Knowledge (Master/Domains),
31157
31277
  Insights (Logs) \u2014 each engraved with its purpose, and writes brainllm.json. Active
31158
31278
  immediately, no restart needed.`, {}, async () => {
31159
31279
  if (b().root) {
@@ -31164,6 +31284,26 @@ immediately, no restart needed.`, {}, async () => {
31164
31284
  return { id: child.noteId, title: child.title };
31165
31285
  }));
31166
31286
  const saved = saveConfig(brainRef.config);
31287
+ const healed = [];
31288
+ const ensureSingleton = async (slot, title, kind, purpose) => {
31289
+ if (brainRef.config.llm[slot])
31290
+ return;
31291
+ const hit = await trilium.searchNotes(`note.title = '${title}'`, { ancestorNoteId: brainRef.config.llm.root, fastSearch: true, limit: 1 }).catch(() => ({ results: [] }));
31292
+ let id = hit.results[0]?.noteId;
31293
+ if (!id) {
31294
+ const made = await trilium.createNote(brainRef.config.llm.root, title, purposeContent(purpose) + `
31295
+ ` + contentFor(kind, { date: localToday(), body: "" }), "text");
31296
+ id = made.note.noteId;
31297
+ await trilium.addLabel(id, "noteType", kind).catch(() => null);
31298
+ healed.push(`created ${title}`);
31299
+ } else {
31300
+ healed.push(`adopted existing ${title}`);
31301
+ }
31302
+ brainRef.config.llm[slot] = id;
31303
+ };
31304
+ await ensureSingleton("selfcorrection", "Self-correction", "selfcorrection", "A single maintained note of the assistant's own corrections \u2014 the mistakes it has made, what generalises from each, and the rule that prevents a repeat. Split out of Protocols in V12 so orientation stops paying for it on every session start.");
31305
+ if (healed.length)
31306
+ saveConfig(brainRef.config);
31167
31307
  const refreshed = [];
31168
31308
  for (const [id, purpose] of containerPurposes(brainRef.config)) {
31169
31309
  if (!id)
@@ -31182,6 +31322,7 @@ immediately, no restart needed.`, {}, async () => {
31182
31322
  status: "already_initialized",
31183
31323
  message: `BrainLLM structure exists. Config refreshed at: ${saved}`,
31184
31324
  ...refreshed.length ? { purposesRefreshed: refreshed, note: "These containers described themselves with text that no longer matched the canonical purpose, and have been re-engraved. Container notes are unreachable through revise(), so bootstrap is the only path that can correct them." } : {},
31325
+ ...healed.length ? { singletonsHealed: healed, healNote: "A singleton introduced by a newer version was missing from this brain and has been created (or an existing note by that title adopted), with its id persisted to the config." } : {},
31185
31326
  root: { id: existing.noteId, title: existing.title },
31186
31327
  children
31187
31328
  });
@@ -31554,6 +31695,112 @@ function applyToolAnnotations(server) {
31554
31695
  return { annotated, unclassified };
31555
31696
  }
31556
31697
 
31698
+ // src/sse.ts
31699
+ import { randomUUID } from "crypto";
31700
+ var KEEPALIVE_MS = 30000;
31701
+
31702
+ class BunSseServerTransport {
31703
+ endpointPath;
31704
+ sessionId = randomUUID();
31705
+ onclose;
31706
+ onerror;
31707
+ onmessage;
31708
+ controller = null;
31709
+ encoder = new TextEncoder;
31710
+ keepalive = null;
31711
+ closed = false;
31712
+ constructor(endpointPath) {
31713
+ this.endpointPath = endpointPath;
31714
+ }
31715
+ streamResponse() {
31716
+ const self = this;
31717
+ const stream = new ReadableStream({
31718
+ start(controller) {
31719
+ self.controller = controller;
31720
+ const url = new URL(self.endpointPath, "http://placeholder.local");
31721
+ url.searchParams.set("sessionId", self.sessionId);
31722
+ self.write(`event: endpoint
31723
+ data: ${url.pathname}${url.search}
31724
+
31725
+ `);
31726
+ self.keepalive = setInterval(() => self.write(`: ping
31727
+
31728
+ `), KEEPALIVE_MS);
31729
+ },
31730
+ cancel() {
31731
+ self.terminate();
31732
+ }
31733
+ });
31734
+ return new Response(stream, {
31735
+ headers: {
31736
+ "Content-Type": "text/event-stream",
31737
+ "Cache-Control": "no-store",
31738
+ Connection: "keep-alive"
31739
+ }
31740
+ });
31741
+ }
31742
+ async handlePost(req) {
31743
+ const url = new URL(req.url);
31744
+ if (url.searchParams.get("sessionId") !== this.sessionId) {
31745
+ return new Response(JSON.stringify({ error: "Session not found" }), {
31746
+ status: 404,
31747
+ headers: { "Content-Type": "application/json" }
31748
+ });
31749
+ }
31750
+ let message;
31751
+ try {
31752
+ message = await req.json();
31753
+ } catch {
31754
+ return new Response(JSON.stringify({ error: "invalid_request", error_description: "Body must be JSON." }), {
31755
+ status: 400,
31756
+ headers: { "Content-Type": "application/json" }
31757
+ });
31758
+ }
31759
+ try {
31760
+ this.onmessage?.(message);
31761
+ } catch (e) {
31762
+ this.onerror?.(e instanceof Error ? e : new Error(String(e)));
31763
+ }
31764
+ return new Response(null, { status: 202 });
31765
+ }
31766
+ async start() {}
31767
+ async send(message, _options) {
31768
+ if (this.closed)
31769
+ throw new Error("SSE transport is closed");
31770
+ this.write(`event: message
31771
+ data: ${JSON.stringify(message)}
31772
+
31773
+ `);
31774
+ }
31775
+ async close() {
31776
+ this.terminate();
31777
+ }
31778
+ write(chunk) {
31779
+ if (this.closed || !this.controller)
31780
+ return;
31781
+ try {
31782
+ this.controller.enqueue(this.encoder.encode(chunk));
31783
+ } catch (e) {
31784
+ this.onerror?.(e instanceof Error ? e : new Error(String(e)));
31785
+ this.terminate();
31786
+ }
31787
+ }
31788
+ terminate() {
31789
+ if (this.closed)
31790
+ return;
31791
+ this.closed = true;
31792
+ if (this.keepalive) {
31793
+ clearInterval(this.keepalive);
31794
+ this.keepalive = null;
31795
+ }
31796
+ try {
31797
+ this.controller?.close();
31798
+ } catch {}
31799
+ this.controller = null;
31800
+ this.onclose?.();
31801
+ }
31802
+ }
31803
+
31557
31804
  // src/oauth.ts
31558
31805
  import { createHmac, randomBytes, createHash, timingSafeEqual } from "crypto";
31559
31806
  import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
@@ -31589,6 +31836,7 @@ function verifyJwt(token, secret) {
31589
31836
  return null;
31590
31837
  }
31591
31838
  }
31839
+ var MAX_REGISTERED_CLIENTS = 200;
31592
31840
  function storePath() {
31593
31841
  return configFilePath().replace(/\.json$/, "") + ".oauth.json";
31594
31842
  }
@@ -31601,12 +31849,12 @@ function loadStore() {
31601
31849
  try {
31602
31850
  const parsed = JSON.parse(readFileSync2(path, "utf-8"));
31603
31851
  if (typeof parsed.secret === "string" && parsed.secret) {
31604
- cache = { secret: parsed.secret, codes: parsed.codes ?? {}, refresh: parsed.refresh ?? {} };
31852
+ cache = { secret: parsed.secret, codes: parsed.codes ?? {}, refresh: parsed.refresh ?? {}, clients: parsed.clients ?? {} };
31605
31853
  return cache;
31606
31854
  }
31607
31855
  } catch {}
31608
31856
  }
31609
- cache = { secret: randomBytes(32).toString("hex"), codes: {}, refresh: {} };
31857
+ cache = { secret: randomBytes(32).toString("hex"), codes: {}, refresh: {}, clients: {} };
31610
31858
  saveStore();
31611
31859
  return cache;
31612
31860
  }
@@ -31620,6 +31868,12 @@ function saveStore() {
31620
31868
  for (const [k, v] of Object.entries(cache.refresh))
31621
31869
  if (v.expiresAt < now)
31622
31870
  delete cache.refresh[k];
31871
+ const regs = Object.entries(cache.clients ?? {});
31872
+ if (regs.length > MAX_REGISTERED_CLIENTS) {
31873
+ regs.sort(([, a], [, b]) => a.issuedAt - b.issuedAt);
31874
+ for (const [k] of regs.slice(0, regs.length - MAX_REGISTERED_CLIENTS))
31875
+ delete cache.clients[k];
31876
+ }
31623
31877
  try {
31624
31878
  writeFileSync2(storePath(), JSON.stringify(cache), { mode: 384 });
31625
31879
  } catch {}
@@ -31664,6 +31918,7 @@ function authorizationServerMetadata(base) {
31664
31918
  scopes_supported: [SCOPE],
31665
31919
  response_types_supported: ["code"],
31666
31920
  grant_types_supported: ["authorization_code", "refresh_token"],
31921
+ registration_endpoint: `${base}/register`,
31667
31922
  token_endpoint_auth_methods_supported: ["none"],
31668
31923
  client_id_metadata_document_supported: true,
31669
31924
  code_challenge_methods_supported: ["S256"],
@@ -31731,6 +31986,16 @@ function validateClientDocument(clientIdUrl, doc2) {
31731
31986
  return { client: d };
31732
31987
  }
31733
31988
  async function resolveClient(clientId) {
31989
+ const registered = loadStore().clients?.[clientId];
31990
+ if (registered) {
31991
+ return {
31992
+ client: {
31993
+ client_id: clientId,
31994
+ client_name: registered.clientName,
31995
+ redirect_uris: registered.redirectUris
31996
+ }
31997
+ };
31998
+ }
31734
31999
  let url;
31735
32000
  try {
31736
32001
  url = new URL(clientId);
@@ -31753,6 +32018,79 @@ async function resolveClient(clientId) {
31753
32018
  }
31754
32019
  return validateClientDocument(url.href, doc2);
31755
32020
  }
32021
+ var MAX_REDIRECT_URIS = 5;
32022
+ function validateRegistration(body) {
32023
+ if (!body || typeof body !== "object")
32024
+ return { error: "registration request is not a JSON object" };
32025
+ const b = body;
32026
+ const rawUris = b.redirect_uris;
32027
+ if (!Array.isArray(rawUris) || rawUris.length === 0) {
32028
+ return { error: "redirect_uris must be a non-empty array" };
32029
+ }
32030
+ if (rawUris.length > MAX_REDIRECT_URIS) {
32031
+ return { error: `redirect_uris may list at most ${MAX_REDIRECT_URIS} entries` };
32032
+ }
32033
+ for (const entry of rawUris) {
32034
+ let r;
32035
+ try {
32036
+ r = new URL(String(entry));
32037
+ } catch {
32038
+ return { error: `invalid redirect_uri: ${String(entry)}` };
32039
+ }
32040
+ if (isLoopback(r))
32041
+ continue;
32042
+ if (r.protocol !== "https:")
32043
+ return { error: "non-loopback redirect_uris must use https" };
32044
+ }
32045
+ const clientName = typeof b.client_name === "string" ? b.client_name : undefined;
32046
+ return { redirectUris: rawUris.map((u) => String(u)), ...clientName ? { clientName } : {} };
32047
+ }
32048
+ async function handleRegister(req) {
32049
+ if (req.method !== "POST") {
32050
+ return new Response(JSON.stringify({ error: "invalid_request", error_description: "POST required." }), {
32051
+ status: 405,
32052
+ headers: { "Content-Type": "application/json", Allow: "POST", "Cache-Control": "no-store" }
32053
+ });
32054
+ }
32055
+ let body;
32056
+ try {
32057
+ body = await req.json();
32058
+ } catch {
32059
+ return new Response(JSON.stringify({ error: "invalid_client_metadata", error_description: "Body must be JSON." }), {
32060
+ status: 400,
32061
+ headers: { "Content-Type": "application/json", "Cache-Control": "no-store" }
32062
+ });
32063
+ }
32064
+ const validated = validateRegistration(body);
32065
+ if ("error" in validated) {
32066
+ return new Response(JSON.stringify({ error: "invalid_redirect_uri", error_description: validated.error }), {
32067
+ status: 400,
32068
+ headers: { "Content-Type": "application/json", "Cache-Control": "no-store" }
32069
+ });
32070
+ }
32071
+ const clientId = `reg_${randomBytes(12).toString("hex")}`;
32072
+ const store = loadStore();
32073
+ store.clients = store.clients ?? {};
32074
+ store.clients[clientId] = {
32075
+ redirectUris: validated.redirectUris,
32076
+ ...validated.clientName ? { clientName: validated.clientName } : {},
32077
+ issuedAt: Date.now()
32078
+ };
32079
+ saveStore();
32080
+ return new Response(JSON.stringify({
32081
+ client_id: clientId,
32082
+ client_id_issued_at: Math.floor(Date.now() / 1000),
32083
+ client_name: validated.clientName,
32084
+ redirect_uris: validated.redirectUris,
32085
+ token_endpoint_auth_method: "none",
32086
+ grant_types: ["authorization_code", "refresh_token"],
32087
+ response_types: ["code"],
32088
+ scope: SCOPE
32089
+ }), {
32090
+ status: 201,
32091
+ headers: { "Content-Type": "application/json", "Cache-Control": "no-store" }
32092
+ });
32093
+ }
31756
32094
  var esc2 = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
31757
32095
  var PAGE_CSS = `
31758
32096
  :root {
@@ -31828,8 +32166,19 @@ var shell = (title, body) => `<!doctype html>
31828
32166
  <title>${esc2(title)}</title>
31829
32167
  <style>${PAGE_CSS}</style></head>
31830
32168
  <body>${body}</body></html>`;
31831
- function consentPage(params, clientHost, error2) {
32169
+ function landingPage(base, oauthOn, sseOn) {
32170
+ return shell("BrainLLM \u2014 a persistent memory server", `<div class="card">
32171
+ <div class="brand">${BRAND_MARK}<span class="brand-name">BrainLLM</span></div>
32172
+ <h1>A brain is listening</h1>
32173
+ <p>This is a <strong>BrainLLM</strong> MCP memory server \u2014 a persistent, graph-structured second brain served over the Model Context Protocol.</p>
32174
+ <p>Point an MCP client at <span class="host">${esc2(base)}/mcp</span>${sseOn ? ` \u2014 or, for clients that only speak the legacy SSE transport, <span class="host">${esc2(base)}/sse</span>` : ""}.</p>
32175
+ <p>${oauthOn ? `Authentication: OAuth 2.1 with owner consent, or a static bearer token (<span class="host">MCP_AUTH_TOKEN</span>). Both work against the same brain.` : `Authentication: a static bearer token (<span class="host">MCP_AUTH_TOKEN</span>).`}</p>
32176
+ <p class="foot">Health: <span class="host">/health</span> \xB7 Everything else is MCP.</p>
32177
+ </div>`);
32178
+ }
32179
+ function consentPage(params, clientHost, error2, verifiedHost = true) {
31832
32180
  const hidden = Object.entries(params).map(([k, v]) => `<input type="hidden" name="${esc2(k)}" value="${esc2(v)}">`).join("");
32181
+ const foot = verifiedHost ? "Only the host above is shown, and it is the one DNS and TLS vouch for." : "The name above is self-reported by the application \u2014 your password is what authorizes access.";
31833
32182
  return shell("Authorize access to your brain", `<form class="card" method="POST" action="/authorize">
31834
32183
  <div class="brand">${BRAND_MARK}<span class="brand-name">BrainLLM</span></div>
31835
32184
  <h1>Authorize access</h1>
@@ -31843,7 +32192,7 @@ function consentPage(params, clientHost, error2) {
31843
32192
  <button class="deny" type="submit" name="decision" value="deny">Deny</button>
31844
32193
  <button class="approve" type="submit" name="decision" value="approve">Authorize</button>
31845
32194
  </div>
31846
- <p class="foot">Only the host above is shown, and it is the one DNS and TLS vouch for.</p>
32195
+ <p class="foot">${foot}</p>
31847
32196
  </form>`);
31848
32197
  }
31849
32198
  var redirectWith = (uri, params) => {
@@ -31887,7 +32236,14 @@ async function handleAuthorize(req, base) {
31887
32236
  if (resource && resource.replace(/\/+$/, "") !== resourceUri(base).replace(/\/+$/, "")) {
31888
32237
  return fail("invalid_target", `This server only issues tokens for ${resourceUri(base)}.`);
31889
32238
  }
31890
- const clientHost = new URL(clientId).host;
32239
+ let clientHost;
32240
+ let verifiedHost = true;
32241
+ try {
32242
+ clientHost = new URL(clientId).host;
32243
+ } catch {
32244
+ verifiedHost = false;
32245
+ clientHost = resolved.client.client_name ?? "a dynamically registered client";
32246
+ }
31891
32247
  const carried = {
31892
32248
  client_id: clientId,
31893
32249
  redirect_uri: redirectUri,
@@ -31899,7 +32255,7 @@ async function handleAuthorize(req, base) {
31899
32255
  ...resource ? { resource } : {}
31900
32256
  };
31901
32257
  if (!form) {
31902
- return new Response(consentPage(carried, clientHost), {
32258
+ return new Response(consentPage(carried, clientHost, undefined, verifiedHost), {
31903
32259
  headers: { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" }
31904
32260
  });
31905
32261
  }
@@ -31907,7 +32263,7 @@ async function handleAuthorize(req, base) {
31907
32263
  return fail("access_denied", "The owner denied the request.");
31908
32264
  }
31909
32265
  if (!ownerPasswordMatches(get("password"))) {
31910
- return new Response(consentPage(carried, clientHost, "Incorrect password."), {
32266
+ return new Response(consentPage(carried, clientHost, "Incorrect password.", verifiedHost), {
31911
32267
  status: 401,
31912
32268
  headers: { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" }
31913
32269
  });
@@ -32075,7 +32431,7 @@ function createServer(origin = null) {
32075
32431
  const s = new McpServer({
32076
32432
  name: "BrainLLM",
32077
32433
  title: "BrainLLM",
32078
- version: "10.5.2",
32434
+ version: "12.0.0",
32079
32435
  icons: brandingIcons(origin)
32080
32436
  });
32081
32437
  registerTools(s, trilium, brainRef);
@@ -32089,6 +32445,7 @@ function createServer(origin = null) {
32089
32445
  }
32090
32446
  if (port) {
32091
32447
  const sessions = new Map;
32448
+ const sseSessions = new Map;
32092
32449
  const CORS_HEADERS = {
32093
32450
  "Access-Control-Allow-Origin": "*",
32094
32451
  "Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS",
@@ -32108,6 +32465,12 @@ if (port) {
32108
32465
  if (entry.lastUsed < cutoff)
32109
32466
  sessions.delete(id);
32110
32467
  }
32468
+ for (const [id, entry] of sseSessions) {
32469
+ if (entry.lastUsed < cutoff) {
32470
+ sseSessions.delete(id);
32471
+ entry.transport.close().catch(() => {});
32472
+ }
32473
+ }
32111
32474
  }, 15 * 60 * 1000).unref();
32112
32475
  Bun.serve({
32113
32476
  port,
@@ -32153,7 +32516,7 @@ if (port) {
32153
32516
  if (url.pathname === "/.well-known/oauth-protected-resource" || url.pathname === "/.well-known/oauth-protected-resource/mcp") {
32154
32517
  return json(protectedResourceMetadata(base));
32155
32518
  }
32156
- if (url.pathname === "/.well-known/oauth-authorization-server" || url.pathname === "/.well-known/openid-configuration") {
32519
+ if (url.pathname === "/.well-known/oauth-authorization-server" || url.pathname === "/.well-known/oauth-authorization-server/mcp" || url.pathname === "/.well-known/openid-configuration") {
32157
32520
  return json(authorizationServerMetadata(base));
32158
32521
  }
32159
32522
  if (url.pathname === "/authorize") {
@@ -32162,21 +32525,62 @@ if (port) {
32162
32525
  if (url.pathname === "/token") {
32163
32526
  return withCors(await handleToken(req, base));
32164
32527
  }
32528
+ if (url.pathname === "/register") {
32529
+ return withCors(await handleRegister(req));
32530
+ }
32531
+ }
32532
+ if (url.pathname === "/") {
32533
+ return withCors(new Response(landingPage(base, oauthOn, true), {
32534
+ headers: { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" }
32535
+ }));
32165
32536
  }
32166
- if (url.pathname !== "/mcp") {
32537
+ if (url.pathname !== "/mcp" && url.pathname !== "/sse" && url.pathname !== "/messages") {
32167
32538
  return withCors(new Response("Not Found", { status: 404 }));
32168
32539
  }
32169
- if (authToken || oauthOn) {
32540
+ const gate = () => {
32541
+ if (!authToken && !oauthOn)
32542
+ return null;
32170
32543
  const header = req.headers.get("Authorization") ?? "";
32171
32544
  const bearer = header.startsWith("Bearer ") ? header.slice(7) : "";
32172
32545
  const staticOk = !!authToken && bearer === authToken;
32173
32546
  const oauthOk = oauthOn && !!bearer && validateAccessToken(bearer, base);
32174
- if (!staticOk && !oauthOk) {
32175
- const headers = { "Content-Type": "application/json" };
32176
- if (oauthOn)
32177
- headers["WWW-Authenticate"] = wwwAuthenticate(base, bearer ? "invalid_token" : undefined);
32178
- return withCors(new Response(JSON.stringify({ error: "invalid_token", error_description: "Authentication required." }), { status: 401, headers }));
32547
+ if (staticOk || oauthOk)
32548
+ return null;
32549
+ const headers = { "Content-Type": "application/json" };
32550
+ if (oauthOn)
32551
+ headers["WWW-Authenticate"] = wwwAuthenticate(base, bearer ? "invalid_token" : undefined);
32552
+ return withCors(new Response(JSON.stringify({ error: "invalid_token", error_description: "Authentication required." }), { status: 401, headers }));
32553
+ };
32554
+ if (url.pathname === "/sse") {
32555
+ if (req.method !== "GET") {
32556
+ return withCors(new Response("Method Not Allowed", { status: 405, headers: { Allow: "GET" } }));
32557
+ }
32558
+ const denied = gate();
32559
+ if (denied)
32560
+ return denied;
32561
+ const transport = new BunSseServerTransport("/messages");
32562
+ sseSessions.set(transport.sessionId, { transport, lastUsed: Date.now() });
32563
+ transport.onclose = () => sseSessions.delete(transport.sessionId);
32564
+ await createServer(base).connect(transport);
32565
+ return withCors(transport.streamResponse());
32566
+ }
32567
+ if (url.pathname === "/messages") {
32568
+ if (req.method !== "POST") {
32569
+ return withCors(new Response("Method Not Allowed", { status: 405, headers: { Allow: "POST" } }));
32570
+ }
32571
+ const denied = gate();
32572
+ if (denied)
32573
+ return denied;
32574
+ const sid = url.searchParams.get("sessionId") ?? "";
32575
+ const entry = sseSessions.get(sid);
32576
+ if (!entry) {
32577
+ return withCors(new Response(JSON.stringify({ error: "Session not found" }), {
32578
+ status: 404,
32579
+ headers: { "Content-Type": "application/json" }
32580
+ }));
32179
32581
  }
32582
+ entry.lastUsed = Date.now();
32583
+ return withCors(await entry.transport.handlePost(req));
32180
32584
  }
32181
32585
  const sessionId = req.headers.get("mcp-session-id");
32182
32586
  if (req.method === "DELETE") {