@hasna/contacts 0.6.34 → 0.6.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +10 -1
  2. package/dashboard/dist/assets/index-0l6aQb1t.css +1 -0
  3. package/dashboard/dist/assets/index-opnZdkVD.js +229 -0
  4. package/dashboard/dist/index.html +13 -0
  5. package/dist/cli/commands/advanced.d.ts +3 -0
  6. package/dist/cli/commands/advanced.d.ts.map +1 -0
  7. package/dist/cli/commands/audience.d.ts +18 -0
  8. package/dist/cli/commands/audience.d.ts.map +1 -0
  9. package/dist/cli/commands/core.d.ts +3 -0
  10. package/dist/cli/commands/core.d.ts.map +1 -0
  11. package/dist/cli/commands/crm.d.ts +3 -0
  12. package/dist/cli/commands/crm.d.ts.map +1 -0
  13. package/dist/cli/index.d.ts +3 -0
  14. package/dist/cli/index.d.ts.map +1 -0
  15. package/dist/cli/index.js +2994 -579
  16. package/dist/cli/storage.d.ts +3 -0
  17. package/dist/cli/storage.d.ts.map +1 -0
  18. package/dist/cli/utils.d.ts +10 -0
  19. package/dist/cli/utils.d.ts.map +1 -0
  20. package/dist/cloud/http-storage.d.ts +88 -0
  21. package/dist/cloud/http-storage.d.ts.map +1 -0
  22. package/dist/db/activity.d.ts +15 -0
  23. package/dist/db/activity.d.ts.map +1 -0
  24. package/dist/db/applications.d.ts +10 -0
  25. package/dist/db/applications.d.ts.map +1 -0
  26. package/dist/db/audiences.d.ts +51 -0
  27. package/dist/db/audiences.d.ts.map +1 -0
  28. package/dist/db/companies.d.ts +19 -0
  29. package/dist/db/companies.d.ts.map +1 -0
  30. package/dist/db/contact-tasks.d.ts +19 -0
  31. package/dist/db/contact-tasks.d.ts.map +1 -0
  32. package/dist/db/contacts.d.ts +30 -0
  33. package/dist/db/contacts.d.ts.map +1 -0
  34. package/dist/db/coordination.d.ts +30 -0
  35. package/dist/db/coordination.d.ts.map +1 -0
  36. package/dist/db/database.d.ts +8 -0
  37. package/dist/db/database.d.ts.map +1 -0
  38. package/dist/db/deals.d.ts +14 -0
  39. package/dist/db/deals.d.ts.map +1 -0
  40. package/dist/db/documents.d.ts +38 -0
  41. package/dist/db/documents.d.ts.map +1 -0
  42. package/dist/db/events.d.ts +14 -0
  43. package/dist/db/events.d.ts.map +1 -0
  44. package/dist/db/field-history.d.ts +17 -0
  45. package/dist/db/field-history.d.ts.map +1 -0
  46. package/dist/db/freshness.d.ts +24 -0
  47. package/dist/db/freshness.d.ts.map +1 -0
  48. package/dist/db/graph.d.ts +21 -0
  49. package/dist/db/graph.d.ts.map +1 -0
  50. package/dist/db/groups.d.ts +22 -0
  51. package/dist/db/groups.d.ts.map +1 -0
  52. package/dist/db/health.d.ts +40 -0
  53. package/dist/db/health.d.ts.map +1 -0
  54. package/dist/db/identity.d.ts +32 -0
  55. package/dist/db/identity.d.ts.map +1 -0
  56. package/dist/db/job-history.d.ts +29 -0
  57. package/dist/db/job-history.d.ts.map +1 -0
  58. package/dist/db/learnings.d.ts +43 -0
  59. package/dist/db/learnings.d.ts.map +1 -0
  60. package/dist/db/notes.d.ts +8 -0
  61. package/dist/db/notes.d.ts.map +1 -0
  62. package/dist/db/org-chart.d.ts +37 -0
  63. package/dist/db/org-chart.d.ts.map +1 -0
  64. package/dist/db/org-members.d.ts +9 -0
  65. package/dist/db/org-members.d.ts.map +1 -0
  66. package/dist/db/paths.d.ts +15 -0
  67. package/dist/db/paths.d.ts.map +1 -0
  68. package/dist/db/pg-migrations.d.ts +8 -0
  69. package/dist/db/pg-migrations.d.ts.map +1 -0
  70. package/dist/db/project-memberships.d.ts +8 -0
  71. package/dist/db/project-memberships.d.ts.map +1 -0
  72. package/dist/db/relationships.d.ts +30 -0
  73. package/dist/db/relationships.d.ts.map +1 -0
  74. package/dist/db/signals.d.ts +18 -0
  75. package/dist/db/signals.d.ts.map +1 -0
  76. package/dist/db/sqlite-adapter.d.ts +15 -0
  77. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  78. package/dist/db/storage.d.ts +15 -0
  79. package/dist/db/storage.d.ts.map +1 -0
  80. package/dist/db/tags.d.ts +14 -0
  81. package/dist/db/tags.d.ts.map +1 -0
  82. package/dist/db/tombstones.d.ts +19 -0
  83. package/dist/db/tombstones.d.ts.map +1 -0
  84. package/dist/db/vendor-comms.d.ts +15 -0
  85. package/dist/db/vendor-comms.d.ts.map +1 -0
  86. package/dist/generated/storage-kit/health.d.ts +20 -0
  87. package/dist/generated/storage-kit/health.d.ts.map +1 -0
  88. package/dist/generated/storage-kit/index.d.ts +8 -0
  89. package/dist/generated/storage-kit/index.d.ts.map +1 -0
  90. package/dist/generated/storage-kit/migrations.d.ts +48 -0
  91. package/dist/generated/storage-kit/migrations.d.ts.map +1 -0
  92. package/dist/generated/storage-kit/mode.d.ts +48 -0
  93. package/dist/generated/storage-kit/mode.d.ts.map +1 -0
  94. package/dist/generated/storage-kit/pool.d.ts +34 -0
  95. package/dist/generated/storage-kit/pool.d.ts.map +1 -0
  96. package/dist/generated/storage-kit/query.d.ts +36 -0
  97. package/dist/generated/storage-kit/query.d.ts.map +1 -0
  98. package/dist/generated/storage-kit/tls.d.ts +26 -0
  99. package/dist/generated/storage-kit/tls.d.ts.map +1 -0
  100. package/dist/index.d.ts +9 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js +805 -75
  103. package/dist/lib/apple-contacts.d.ts +3 -0
  104. package/dist/lib/apple-contacts.d.ts.map +1 -0
  105. package/dist/lib/audience-contract.d.ts +215 -0
  106. package/dist/lib/audience-contract.d.ts.map +1 -0
  107. package/dist/lib/audit.d.ts +12 -0
  108. package/dist/lib/audit.d.ts.map +1 -0
  109. package/dist/lib/brief.d.ts +3 -0
  110. package/dist/lib/brief.d.ts.map +1 -0
  111. package/dist/lib/config.d.ts +7 -0
  112. package/dist/lib/config.d.ts.map +1 -0
  113. package/dist/lib/connector.d.ts +44 -0
  114. package/dist/lib/connector.d.ts.map +1 -0
  115. package/dist/lib/context.d.ts +5 -0
  116. package/dist/lib/context.d.ts.map +1 -0
  117. package/dist/lib/dedup.d.ts +10 -0
  118. package/dist/lib/dedup.d.ts.map +1 -0
  119. package/dist/lib/document-scanner.d.ts +8 -0
  120. package/dist/lib/document-scanner.d.ts.map +1 -0
  121. package/dist/lib/embeddings.d.ts +9 -0
  122. package/dist/lib/embeddings.d.ts.map +1 -0
  123. package/dist/lib/export.d.ts +8 -0
  124. package/dist/lib/export.d.ts.map +1 -0
  125. package/dist/lib/freshness.d.ts +19 -0
  126. package/dist/lib/freshness.d.ts.map +1 -0
  127. package/dist/lib/gmail-import.d.ts +51 -0
  128. package/dist/lib/gmail-import.d.ts.map +1 -0
  129. package/dist/lib/google-contacts.d.ts +115 -0
  130. package/dist/lib/google-contacts.d.ts.map +1 -0
  131. package/dist/lib/images.d.ts +30 -0
  132. package/dist/lib/images.d.ts.map +1 -0
  133. package/dist/lib/import.d.ts +10 -0
  134. package/dist/lib/import.d.ts.map +1 -0
  135. package/dist/lib/learning-maintenance.d.ts +8 -0
  136. package/dist/lib/learning-maintenance.d.ts.map +1 -0
  137. package/dist/lib/mailery-sync.d.ts +46 -0
  138. package/dist/lib/mailery-sync.d.ts.map +1 -0
  139. package/dist/lib/meeting-capture.d.ts +15 -0
  140. package/dist/lib/meeting-capture.d.ts.map +1 -0
  141. package/dist/lib/package-version.d.ts +6 -0
  142. package/dist/lib/package-version.d.ts.map +1 -0
  143. package/dist/lib/signals.d.ts +9 -0
  144. package/dist/lib/signals.d.ts.map +1 -0
  145. package/dist/lib/signature-parser.d.ts +36 -0
  146. package/dist/lib/signature-parser.d.ts.map +1 -0
  147. package/dist/lib/stats.d.ts +24 -0
  148. package/dist/lib/stats.d.ts.map +1 -0
  149. package/dist/lib/timeline.d.ts +11 -0
  150. package/dist/lib/timeline.d.ts.map +1 -0
  151. package/dist/lib/upcoming.d.ts +14 -0
  152. package/dist/lib/upcoming.d.ts.map +1 -0
  153. package/dist/lib/vault.d.ts +28 -0
  154. package/dist/lib/vault.d.ts.map +1 -0
  155. package/dist/mcp/handlers/advanced.d.ts +14 -0
  156. package/dist/mcp/handlers/advanced.d.ts.map +1 -0
  157. package/dist/mcp/handlers/audience.d.ts +9 -0
  158. package/dist/mcp/handlers/audience.d.ts.map +1 -0
  159. package/dist/mcp/handlers/core.d.ts +10 -0
  160. package/dist/mcp/handlers/core.d.ts.map +1 -0
  161. package/dist/mcp/handlers/crm.d.ts +14 -0
  162. package/dist/mcp/handlers/crm.d.ts.map +1 -0
  163. package/dist/mcp/handlers/index.d.ts +4 -0
  164. package/dist/mcp/handlers/index.d.ts.map +1 -0
  165. package/dist/mcp/handlers/types.d.ts +10 -0
  166. package/dist/mcp/handlers/types.d.ts.map +1 -0
  167. package/dist/mcp/http.d.ts +17 -0
  168. package/dist/mcp/http.d.ts.map +1 -0
  169. package/dist/mcp/index.d.ts +5 -0
  170. package/dist/mcp/index.d.ts.map +1 -0
  171. package/dist/mcp/index.js +1054 -291
  172. package/dist/mcp/register-tools.d.ts +3 -0
  173. package/dist/mcp/register-tools.d.ts.map +1 -0
  174. package/dist/mcp/schema.d.ts +3 -0
  175. package/dist/mcp/schema.d.ts.map +1 -0
  176. package/dist/mcp/storage-tools.d.ts +3 -0
  177. package/dist/mcp/storage-tools.d.ts.map +1 -0
  178. package/dist/mcp/tools.d.ts +3799 -0
  179. package/dist/mcp/tools.d.ts.map +1 -0
  180. package/dist/sdk/index.d.ts +16 -0
  181. package/dist/sdk/index.d.ts.map +1 -0
  182. package/dist/sdk/index.js +63 -0
  183. package/dist/sdk/v1.generated.d.ts +270 -0
  184. package/dist/sdk/v1.generated.d.ts.map +1 -0
  185. package/dist/server/cloud-index.d.ts +3 -0
  186. package/dist/server/cloud-index.d.ts.map +1 -0
  187. package/dist/server/cloud-serve.d.ts +3 -0
  188. package/dist/server/cloud-serve.d.ts.map +1 -0
  189. package/dist/server/cloud.d.ts +53 -0
  190. package/dist/server/cloud.d.ts.map +1 -0
  191. package/dist/server/index.d.ts +3 -0
  192. package/dist/server/index.d.ts.map +1 -0
  193. package/dist/server/index.js +1750 -332
  194. package/dist/server/openapi.d.ts +1134 -0
  195. package/dist/server/openapi.d.ts.map +1 -0
  196. package/dist/server/pg-store.d.ts +893 -0
  197. package/dist/server/pg-store.d.ts.map +1 -0
  198. package/dist/server/security.d.ts +24 -0
  199. package/dist/server/security.d.ts.map +1 -0
  200. package/dist/server/serve.d.ts +9 -0
  201. package/dist/server/serve.d.ts.map +1 -0
  202. package/dist/server/v1.d.ts +28 -0
  203. package/dist/server/v1.d.ts.map +1 -0
  204. package/dist/store/index.d.ts +387 -0
  205. package/dist/store/index.d.ts.map +1 -0
  206. package/dist/types/index.d.ts +856 -0
  207. package/dist/types/index.d.ts.map +1 -0
  208. package/dist/types/project-memberships.d.ts +32 -0
  209. package/dist/types/project-memberships.d.ts.map +1 -0
  210. package/hasna.contract.json +1 -1
  211. package/migrations/0015_contact_project_membership_authority.sql +88 -0
  212. package/package.json +4 -2
  213. package/vendor/fast-uri/README.md +12 -0
  214. package/dist/server/cloud-index.js +0 -9187
package/dist/mcp/index.js CHANGED
@@ -47,7 +47,7 @@ var __export = (target, all) => {
47
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
48
48
  var __require = import.meta.require;
49
49
 
50
- // node_modules/ajv/dist/compile/codegen/code.js
50
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js
51
51
  var require_code = __commonJS((exports) => {
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
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;
@@ -201,7 +201,7 @@ var require_code = __commonJS((exports) => {
201
201
  exports.regexpCode = regexpCode;
202
202
  });
203
203
 
204
- // node_modules/ajv/dist/compile/codegen/scope.js
204
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js
205
205
  var require_scope = __commonJS((exports) => {
206
206
  Object.defineProperty(exports, "__esModule", { value: true });
207
207
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = undefined;
@@ -347,7 +347,7 @@ var require_scope = __commonJS((exports) => {
347
347
  exports.ValueScope = ValueScope;
348
348
  });
349
349
 
350
- // node_modules/ajv/dist/compile/codegen/index.js
350
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js
351
351
  var require_codegen = __commonJS((exports) => {
352
352
  Object.defineProperty(exports, "__esModule", { value: true });
353
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;
@@ -1057,7 +1057,7 @@ var require_codegen = __commonJS((exports) => {
1057
1057
  }
1058
1058
  });
1059
1059
 
1060
- // node_modules/ajv/dist/compile/util.js
1060
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js
1061
1061
  var require_util = __commonJS((exports) => {
1062
1062
  Object.defineProperty(exports, "__esModule", { value: true });
1063
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;
@@ -1221,7 +1221,7 @@ var require_util = __commonJS((exports) => {
1221
1221
  exports.checkStrictMode = checkStrictMode;
1222
1222
  });
1223
1223
 
1224
- // node_modules/ajv/dist/compile/names.js
1224
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js
1225
1225
  var require_names = __commonJS((exports) => {
1226
1226
  Object.defineProperty(exports, "__esModule", { value: true });
1227
1227
  var codegen_1 = require_codegen();
@@ -1246,7 +1246,7 @@ var require_names = __commonJS((exports) => {
1246
1246
  exports.default = names;
1247
1247
  });
1248
1248
 
1249
- // node_modules/ajv/dist/compile/errors.js
1249
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js
1250
1250
  var require_errors = __commonJS((exports) => {
1251
1251
  Object.defineProperty(exports, "__esModule", { value: true });
1252
1252
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = undefined;
@@ -1364,7 +1364,7 @@ var require_errors = __commonJS((exports) => {
1364
1364
  }
1365
1365
  });
1366
1366
 
1367
- // node_modules/ajv/dist/compile/validate/boolSchema.js
1367
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js
1368
1368
  var require_boolSchema = __commonJS((exports) => {
1369
1369
  Object.defineProperty(exports, "__esModule", { value: true });
1370
1370
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = undefined;
@@ -1412,7 +1412,7 @@ var require_boolSchema = __commonJS((exports) => {
1412
1412
  }
1413
1413
  });
1414
1414
 
1415
- // node_modules/ajv/dist/compile/rules.js
1415
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js
1416
1416
  var require_rules = __commonJS((exports) => {
1417
1417
  Object.defineProperty(exports, "__esModule", { value: true });
1418
1418
  exports.getRules = exports.isJSONType = undefined;
@@ -1440,7 +1440,7 @@ var require_rules = __commonJS((exports) => {
1440
1440
  exports.getRules = getRules;
1441
1441
  });
1442
1442
 
1443
- // node_modules/ajv/dist/compile/validate/applicability.js
1443
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js
1444
1444
  var require_applicability = __commonJS((exports) => {
1445
1445
  Object.defineProperty(exports, "__esModule", { value: true });
1446
1446
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = undefined;
@@ -1460,7 +1460,7 @@ var require_applicability = __commonJS((exports) => {
1460
1460
  exports.shouldUseRule = shouldUseRule;
1461
1461
  });
1462
1462
 
1463
- // node_modules/ajv/dist/compile/validate/dataType.js
1463
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js
1464
1464
  var require_dataType = __commonJS((exports) => {
1465
1465
  Object.defineProperty(exports, "__esModule", { value: true });
1466
1466
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = undefined;
@@ -1641,7 +1641,7 @@ var require_dataType = __commonJS((exports) => {
1641
1641
  }
1642
1642
  });
1643
1643
 
1644
- // node_modules/ajv/dist/compile/validate/defaults.js
1644
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js
1645
1645
  var require_defaults = __commonJS((exports) => {
1646
1646
  Object.defineProperty(exports, "__esModule", { value: true });
1647
1647
  exports.assignDefaults = undefined;
@@ -1675,7 +1675,7 @@ var require_defaults = __commonJS((exports) => {
1675
1675
  }
1676
1676
  });
1677
1677
 
1678
- // node_modules/ajv/dist/vocabularies/code.js
1678
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js
1679
1679
  var require_code2 = __commonJS((exports) => {
1680
1680
  Object.defineProperty(exports, "__esModule", { value: true });
1681
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;
@@ -1804,7 +1804,7 @@ var require_code2 = __commonJS((exports) => {
1804
1804
  exports.validateUnion = validateUnion;
1805
1805
  });
1806
1806
 
1807
- // node_modules/ajv/dist/compile/validate/keyword.js
1807
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js
1808
1808
  var require_keyword = __commonJS((exports) => {
1809
1809
  Object.defineProperty(exports, "__esModule", { value: true });
1810
1810
  exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = undefined;
@@ -1919,7 +1919,7 @@ var require_keyword = __commonJS((exports) => {
1919
1919
  exports.validateKeywordUsage = validateKeywordUsage;
1920
1920
  });
1921
1921
 
1922
- // node_modules/ajv/dist/compile/validate/subschema.js
1922
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js
1923
1923
  var require_subschema = __commonJS((exports) => {
1924
1924
  Object.defineProperty(exports, "__esModule", { value: true });
1925
1925
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = undefined;
@@ -1999,7 +1999,7 @@ var require_subschema = __commonJS((exports) => {
1999
1999
  exports.extendSubschemaMode = extendSubschemaMode;
2000
2000
  });
2001
2001
 
2002
- // node_modules/fast-deep-equal/index.js
2002
+ // node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
2003
2003
  var require_fast_deep_equal = __commonJS((exports, module) => {
2004
2004
  module.exports = function equal(a, b) {
2005
2005
  if (a === b)
@@ -2041,7 +2041,7 @@ var require_fast_deep_equal = __commonJS((exports, module) => {
2041
2041
  };
2042
2042
  });
2043
2043
 
2044
- // node_modules/json-schema-traverse/index.js
2044
+ // node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js
2045
2045
  var require_json_schema_traverse = __commonJS((exports, module) => {
2046
2046
  var traverse = module.exports = function(schema, opts, cb) {
2047
2047
  if (typeof opts == "function") {
@@ -2124,7 +2124,7 @@ var require_json_schema_traverse = __commonJS((exports, module) => {
2124
2124
  }
2125
2125
  });
2126
2126
 
2127
- // node_modules/ajv/dist/compile/resolve.js
2127
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js
2128
2128
  var require_resolve = __commonJS((exports) => {
2129
2129
  Object.defineProperty(exports, "__esModule", { value: true });
2130
2130
  exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = undefined;
@@ -2277,7 +2277,7 @@ var require_resolve = __commonJS((exports) => {
2277
2277
  exports.getSchemaRefs = getSchemaRefs;
2278
2278
  });
2279
2279
 
2280
- // node_modules/ajv/dist/compile/validate/index.js
2280
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js
2281
2281
  var require_validate = __commonJS((exports) => {
2282
2282
  Object.defineProperty(exports, "__esModule", { value: true });
2283
2283
  exports.getData = exports.KeywordCxt = exports.validateFunctionCode = undefined;
@@ -2782,7 +2782,7 @@ var require_validate = __commonJS((exports) => {
2782
2782
  exports.getData = getData;
2783
2783
  });
2784
2784
 
2785
- // node_modules/ajv/dist/runtime/validation_error.js
2785
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js
2786
2786
  var require_validation_error = __commonJS((exports) => {
2787
2787
  Object.defineProperty(exports, "__esModule", { value: true });
2788
2788
 
@@ -2796,7 +2796,7 @@ var require_validation_error = __commonJS((exports) => {
2796
2796
  exports.default = ValidationError;
2797
2797
  });
2798
2798
 
2799
- // node_modules/ajv/dist/compile/ref_error.js
2799
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js
2800
2800
  var require_ref_error = __commonJS((exports) => {
2801
2801
  Object.defineProperty(exports, "__esModule", { value: true });
2802
2802
  var resolve_1 = require_resolve();
@@ -2811,7 +2811,7 @@ var require_ref_error = __commonJS((exports) => {
2811
2811
  exports.default = MissingRefError;
2812
2812
  });
2813
2813
 
2814
- // node_modules/ajv/dist/compile/index.js
2814
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js
2815
2815
  var require_compile = __commonJS((exports) => {
2816
2816
  Object.defineProperty(exports, "__esModule", { value: true });
2817
2817
  exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = undefined;
@@ -3032,7 +3032,7 @@ var require_compile = __commonJS((exports) => {
3032
3032
  }
3033
3033
  });
3034
3034
 
3035
- // node_modules/ajv/dist/refs/data.json
3035
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.json
3036
3036
  var require_data = __commonJS((exports, module) => {
3037
3037
  module.exports = {
3038
3038
  $id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
@@ -3822,7 +3822,7 @@ var require_fast_uri = __commonJS((exports, module) => {
3822
3822
  module.exports.fastUri = fastUri;
3823
3823
  });
3824
3824
 
3825
- // node_modules/ajv/dist/runtime/uri.js
3825
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js
3826
3826
  var require_uri = __commonJS((exports) => {
3827
3827
  Object.defineProperty(exports, "__esModule", { value: true });
3828
3828
  var uri = require_fast_uri();
@@ -3830,7 +3830,7 @@ var require_uri = __commonJS((exports) => {
3830
3830
  exports.default = uri;
3831
3831
  });
3832
3832
 
3833
- // node_modules/ajv/dist/core.js
3833
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js
3834
3834
  var require_core = __commonJS((exports) => {
3835
3835
  Object.defineProperty(exports, "__esModule", { value: true });
3836
3836
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = undefined;
@@ -3941,7 +3941,7 @@ var require_core = __commonJS((exports) => {
3941
3941
  constructor(opts = {}) {
3942
3942
  this.schemas = {};
3943
3943
  this.refs = {};
3944
- this.formats = {};
3944
+ this.formats = Object.create(null);
3945
3945
  this._compilations = new Set;
3946
3946
  this._loading = {};
3947
3947
  this._cache = new Map;
@@ -4423,7 +4423,7 @@ var require_core = __commonJS((exports) => {
4423
4423
  }
4424
4424
  });
4425
4425
 
4426
- // node_modules/ajv/dist/vocabularies/core/id.js
4426
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js
4427
4427
  var require_id = __commonJS((exports) => {
4428
4428
  Object.defineProperty(exports, "__esModule", { value: true });
4429
4429
  var def = {
@@ -4435,7 +4435,7 @@ var require_id = __commonJS((exports) => {
4435
4435
  exports.default = def;
4436
4436
  });
4437
4437
 
4438
- // node_modules/ajv/dist/vocabularies/core/ref.js
4438
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js
4439
4439
  var require_ref = __commonJS((exports) => {
4440
4440
  Object.defineProperty(exports, "__esModule", { value: true });
4441
4441
  exports.callRef = exports.getValidate = undefined;
@@ -4554,7 +4554,7 @@ var require_ref = __commonJS((exports) => {
4554
4554
  exports.default = def;
4555
4555
  });
4556
4556
 
4557
- // node_modules/ajv/dist/vocabularies/core/index.js
4557
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js
4558
4558
  var require_core2 = __commonJS((exports) => {
4559
4559
  Object.defineProperty(exports, "__esModule", { value: true });
4560
4560
  var id_1 = require_id();
@@ -4572,7 +4572,7 @@ var require_core2 = __commonJS((exports) => {
4572
4572
  exports.default = core2;
4573
4573
  });
4574
4574
 
4575
- // node_modules/ajv/dist/vocabularies/validation/limitNumber.js
4575
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
4576
4576
  var require_limitNumber = __commonJS((exports) => {
4577
4577
  Object.defineProperty(exports, "__esModule", { value: true });
4578
4578
  var codegen_1 = require_codegen();
@@ -4601,7 +4601,7 @@ var require_limitNumber = __commonJS((exports) => {
4601
4601
  exports.default = def;
4602
4602
  });
4603
4603
 
4604
- // node_modules/ajv/dist/vocabularies/validation/multipleOf.js
4604
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
4605
4605
  var require_multipleOf = __commonJS((exports) => {
4606
4606
  Object.defineProperty(exports, "__esModule", { value: true });
4607
4607
  var codegen_1 = require_codegen();
@@ -4626,7 +4626,7 @@ var require_multipleOf = __commonJS((exports) => {
4626
4626
  exports.default = def;
4627
4627
  });
4628
4628
 
4629
- // node_modules/ajv/dist/runtime/ucs2length.js
4629
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js
4630
4630
  var require_ucs2length = __commonJS((exports) => {
4631
4631
  Object.defineProperty(exports, "__esModule", { value: true });
4632
4632
  function ucs2length(str) {
@@ -4649,7 +4649,7 @@ var require_ucs2length = __commonJS((exports) => {
4649
4649
  ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default';
4650
4650
  });
4651
4651
 
4652
- // node_modules/ajv/dist/vocabularies/validation/limitLength.js
4652
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js
4653
4653
  var require_limitLength = __commonJS((exports) => {
4654
4654
  Object.defineProperty(exports, "__esModule", { value: true });
4655
4655
  var codegen_1 = require_codegen();
@@ -4678,7 +4678,7 @@ var require_limitLength = __commonJS((exports) => {
4678
4678
  exports.default = def;
4679
4679
  });
4680
4680
 
4681
- // node_modules/ajv/dist/vocabularies/validation/pattern.js
4681
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js
4682
4682
  var require_pattern = __commonJS((exports) => {
4683
4683
  Object.defineProperty(exports, "__esModule", { value: true });
4684
4684
  var code_1 = require_code2();
@@ -4712,7 +4712,7 @@ var require_pattern = __commonJS((exports) => {
4712
4712
  exports.default = def;
4713
4713
  });
4714
4714
 
4715
- // node_modules/ajv/dist/vocabularies/validation/limitProperties.js
4715
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
4716
4716
  var require_limitProperties = __commonJS((exports) => {
4717
4717
  Object.defineProperty(exports, "__esModule", { value: true });
4718
4718
  var codegen_1 = require_codegen();
@@ -4738,7 +4738,7 @@ var require_limitProperties = __commonJS((exports) => {
4738
4738
  exports.default = def;
4739
4739
  });
4740
4740
 
4741
- // node_modules/ajv/dist/vocabularies/validation/required.js
4741
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js
4742
4742
  var require_required = __commonJS((exports) => {
4743
4743
  Object.defineProperty(exports, "__esModule", { value: true });
4744
4744
  var code_1 = require_code2();
@@ -4817,7 +4817,7 @@ var require_required = __commonJS((exports) => {
4817
4817
  exports.default = def;
4818
4818
  });
4819
4819
 
4820
- // node_modules/ajv/dist/vocabularies/validation/limitItems.js
4820
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js
4821
4821
  var require_limitItems = __commonJS((exports) => {
4822
4822
  Object.defineProperty(exports, "__esModule", { value: true });
4823
4823
  var codegen_1 = require_codegen();
@@ -4843,7 +4843,7 @@ var require_limitItems = __commonJS((exports) => {
4843
4843
  exports.default = def;
4844
4844
  });
4845
4845
 
4846
- // node_modules/ajv/dist/runtime/equal.js
4846
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js
4847
4847
  var require_equal = __commonJS((exports) => {
4848
4848
  Object.defineProperty(exports, "__esModule", { value: true });
4849
4849
  var equal = require_fast_deep_equal();
@@ -4851,7 +4851,7 @@ var require_equal = __commonJS((exports) => {
4851
4851
  exports.default = equal;
4852
4852
  });
4853
4853
 
4854
- // node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
4854
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
4855
4855
  var require_uniqueItems = __commonJS((exports) => {
4856
4856
  Object.defineProperty(exports, "__esModule", { value: true });
4857
4857
  var dataType_1 = require_dataType();
@@ -4915,7 +4915,7 @@ var require_uniqueItems = __commonJS((exports) => {
4915
4915
  exports.default = def;
4916
4916
  });
4917
4917
 
4918
- // node_modules/ajv/dist/vocabularies/validation/const.js
4918
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js
4919
4919
  var require_const = __commonJS((exports) => {
4920
4920
  Object.defineProperty(exports, "__esModule", { value: true });
4921
4921
  var codegen_1 = require_codegen();
@@ -4941,7 +4941,7 @@ var require_const = __commonJS((exports) => {
4941
4941
  exports.default = def;
4942
4942
  });
4943
4943
 
4944
- // node_modules/ajv/dist/vocabularies/validation/enum.js
4944
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js
4945
4945
  var require_enum = __commonJS((exports) => {
4946
4946
  Object.defineProperty(exports, "__esModule", { value: true });
4947
4947
  var codegen_1 = require_codegen();
@@ -4987,7 +4987,7 @@ var require_enum = __commonJS((exports) => {
4987
4987
  exports.default = def;
4988
4988
  });
4989
4989
 
4990
- // node_modules/ajv/dist/vocabularies/validation/index.js
4990
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js
4991
4991
  var require_validation = __commonJS((exports) => {
4992
4992
  Object.defineProperty(exports, "__esModule", { value: true });
4993
4993
  var limitNumber_1 = require_limitNumber();
@@ -5017,7 +5017,7 @@ var require_validation = __commonJS((exports) => {
5017
5017
  exports.default = validation;
5018
5018
  });
5019
5019
 
5020
- // node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
5020
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
5021
5021
  var require_additionalItems = __commonJS((exports) => {
5022
5022
  Object.defineProperty(exports, "__esModule", { value: true });
5023
5023
  exports.validateAdditionalItems = undefined;
@@ -5067,7 +5067,7 @@ var require_additionalItems = __commonJS((exports) => {
5067
5067
  exports.default = def;
5068
5068
  });
5069
5069
 
5070
- // node_modules/ajv/dist/vocabularies/applicator/items.js
5070
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js
5071
5071
  var require_items = __commonJS((exports) => {
5072
5072
  Object.defineProperty(exports, "__esModule", { value: true });
5073
5073
  exports.validateTuple = undefined;
@@ -5121,7 +5121,7 @@ var require_items = __commonJS((exports) => {
5121
5121
  exports.default = def;
5122
5122
  });
5123
5123
 
5124
- // node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
5124
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
5125
5125
  var require_prefixItems = __commonJS((exports) => {
5126
5126
  Object.defineProperty(exports, "__esModule", { value: true });
5127
5127
  var items_1 = require_items();
@@ -5135,7 +5135,7 @@ var require_prefixItems = __commonJS((exports) => {
5135
5135
  exports.default = def;
5136
5136
  });
5137
5137
 
5138
- // node_modules/ajv/dist/vocabularies/applicator/items2020.js
5138
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js
5139
5139
  var require_items2020 = __commonJS((exports) => {
5140
5140
  Object.defineProperty(exports, "__esModule", { value: true });
5141
5141
  var codegen_1 = require_codegen();
@@ -5167,7 +5167,7 @@ var require_items2020 = __commonJS((exports) => {
5167
5167
  exports.default = def;
5168
5168
  });
5169
5169
 
5170
- // node_modules/ajv/dist/vocabularies/applicator/contains.js
5170
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js
5171
5171
  var require_contains = __commonJS((exports) => {
5172
5172
  Object.defineProperty(exports, "__esModule", { value: true });
5173
5173
  var codegen_1 = require_codegen();
@@ -5258,7 +5258,7 @@ var require_contains = __commonJS((exports) => {
5258
5258
  exports.default = def;
5259
5259
  });
5260
5260
 
5261
- // node_modules/ajv/dist/vocabularies/applicator/dependencies.js
5261
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
5262
5262
  var require_dependencies = __commonJS((exports) => {
5263
5263
  Object.defineProperty(exports, "__esModule", { value: true });
5264
5264
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = undefined;
@@ -5343,7 +5343,7 @@ var require_dependencies = __commonJS((exports) => {
5343
5343
  exports.default = def;
5344
5344
  });
5345
5345
 
5346
- // node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
5346
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
5347
5347
  var require_propertyNames = __commonJS((exports) => {
5348
5348
  Object.defineProperty(exports, "__esModule", { value: true });
5349
5349
  var codegen_1 = require_codegen();
@@ -5383,7 +5383,7 @@ var require_propertyNames = __commonJS((exports) => {
5383
5383
  exports.default = def;
5384
5384
  });
5385
5385
 
5386
- // node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
5386
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
5387
5387
  var require_additionalProperties = __commonJS((exports) => {
5388
5388
  Object.defineProperty(exports, "__esModule", { value: true });
5389
5389
  var code_1 = require_code2();
@@ -5486,7 +5486,7 @@ var require_additionalProperties = __commonJS((exports) => {
5486
5486
  exports.default = def;
5487
5487
  });
5488
5488
 
5489
- // node_modules/ajv/dist/vocabularies/applicator/properties.js
5489
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js
5490
5490
  var require_properties = __commonJS((exports) => {
5491
5491
  Object.defineProperty(exports, "__esModule", { value: true });
5492
5492
  var validate_1 = require_validate();
@@ -5541,7 +5541,7 @@ var require_properties = __commonJS((exports) => {
5541
5541
  exports.default = def;
5542
5542
  });
5543
5543
 
5544
- // node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
5544
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
5545
5545
  var require_patternProperties = __commonJS((exports) => {
5546
5546
  Object.defineProperty(exports, "__esModule", { value: true });
5547
5547
  var code_1 = require_code2();
@@ -5612,7 +5612,7 @@ var require_patternProperties = __commonJS((exports) => {
5612
5612
  exports.default = def;
5613
5613
  });
5614
5614
 
5615
- // node_modules/ajv/dist/vocabularies/applicator/not.js
5615
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js
5616
5616
  var require_not = __commonJS((exports) => {
5617
5617
  Object.defineProperty(exports, "__esModule", { value: true });
5618
5618
  var util_1 = require_util();
@@ -5640,7 +5640,7 @@ var require_not = __commonJS((exports) => {
5640
5640
  exports.default = def;
5641
5641
  });
5642
5642
 
5643
- // node_modules/ajv/dist/vocabularies/applicator/anyOf.js
5643
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
5644
5644
  var require_anyOf = __commonJS((exports) => {
5645
5645
  Object.defineProperty(exports, "__esModule", { value: true });
5646
5646
  var code_1 = require_code2();
@@ -5654,7 +5654,7 @@ var require_anyOf = __commonJS((exports) => {
5654
5654
  exports.default = def;
5655
5655
  });
5656
5656
 
5657
- // node_modules/ajv/dist/vocabularies/applicator/oneOf.js
5657
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
5658
5658
  var require_oneOf = __commonJS((exports) => {
5659
5659
  Object.defineProperty(exports, "__esModule", { value: true });
5660
5660
  var codegen_1 = require_codegen();
@@ -5709,7 +5709,7 @@ var require_oneOf = __commonJS((exports) => {
5709
5709
  exports.default = def;
5710
5710
  });
5711
5711
 
5712
- // node_modules/ajv/dist/vocabularies/applicator/allOf.js
5712
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js
5713
5713
  var require_allOf = __commonJS((exports) => {
5714
5714
  Object.defineProperty(exports, "__esModule", { value: true });
5715
5715
  var util_1 = require_util();
@@ -5733,7 +5733,7 @@ var require_allOf = __commonJS((exports) => {
5733
5733
  exports.default = def;
5734
5734
  });
5735
5735
 
5736
- // node_modules/ajv/dist/vocabularies/applicator/if.js
5736
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js
5737
5737
  var require_if = __commonJS((exports) => {
5738
5738
  Object.defineProperty(exports, "__esModule", { value: true });
5739
5739
  var codegen_1 = require_codegen();
@@ -5799,7 +5799,7 @@ var require_if = __commonJS((exports) => {
5799
5799
  exports.default = def;
5800
5800
  });
5801
5801
 
5802
- // node_modules/ajv/dist/vocabularies/applicator/thenElse.js
5802
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
5803
5803
  var require_thenElse = __commonJS((exports) => {
5804
5804
  Object.defineProperty(exports, "__esModule", { value: true });
5805
5805
  var util_1 = require_util();
@@ -5814,7 +5814,7 @@ var require_thenElse = __commonJS((exports) => {
5814
5814
  exports.default = def;
5815
5815
  });
5816
5816
 
5817
- // node_modules/ajv/dist/vocabularies/applicator/index.js
5817
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js
5818
5818
  var require_applicator = __commonJS((exports) => {
5819
5819
  Object.defineProperty(exports, "__esModule", { value: true });
5820
5820
  var additionalItems_1 = require_additionalItems();
@@ -5857,7 +5857,7 @@ var require_applicator = __commonJS((exports) => {
5857
5857
  exports.default = getApplicator;
5858
5858
  });
5859
5859
 
5860
- // node_modules/ajv/dist/vocabularies/format/format.js
5860
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js
5861
5861
  var require_format = __commonJS((exports) => {
5862
5862
  Object.defineProperty(exports, "__esModule", { value: true });
5863
5863
  var codegen_1 = require_codegen();
@@ -5944,7 +5944,7 @@ var require_format = __commonJS((exports) => {
5944
5944
  exports.default = def;
5945
5945
  });
5946
5946
 
5947
- // node_modules/ajv/dist/vocabularies/format/index.js
5947
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js
5948
5948
  var require_format2 = __commonJS((exports) => {
5949
5949
  Object.defineProperty(exports, "__esModule", { value: true });
5950
5950
  var format_1 = require_format();
@@ -5952,7 +5952,7 @@ var require_format2 = __commonJS((exports) => {
5952
5952
  exports.default = format;
5953
5953
  });
5954
5954
 
5955
- // node_modules/ajv/dist/vocabularies/metadata.js
5955
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js
5956
5956
  var require_metadata = __commonJS((exports) => {
5957
5957
  Object.defineProperty(exports, "__esModule", { value: true });
5958
5958
  exports.contentVocabulary = exports.metadataVocabulary = undefined;
@@ -5972,7 +5972,7 @@ var require_metadata = __commonJS((exports) => {
5972
5972
  ];
5973
5973
  });
5974
5974
 
5975
- // node_modules/ajv/dist/vocabularies/draft7.js
5975
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft7.js
5976
5976
  var require_draft7 = __commonJS((exports) => {
5977
5977
  Object.defineProperty(exports, "__esModule", { value: true });
5978
5978
  var core_1 = require_core2();
@@ -5991,7 +5991,7 @@ var require_draft7 = __commonJS((exports) => {
5991
5991
  exports.default = draft7Vocabularies;
5992
5992
  });
5993
5993
 
5994
- // node_modules/ajv/dist/vocabularies/discriminator/types.js
5994
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js
5995
5995
  var require_types = __commonJS((exports) => {
5996
5996
  Object.defineProperty(exports, "__esModule", { value: true });
5997
5997
  exports.DiscrError = undefined;
@@ -6002,7 +6002,7 @@ var require_types = __commonJS((exports) => {
6002
6002
  })(DiscrError || (exports.DiscrError = DiscrError = {}));
6003
6003
  });
6004
6004
 
6005
- // node_modules/ajv/dist/vocabularies/discriminator/index.js
6005
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js
6006
6006
  var require_discriminator = __commonJS((exports) => {
6007
6007
  Object.defineProperty(exports, "__esModule", { value: true });
6008
6008
  var codegen_1 = require_codegen();
@@ -6104,7 +6104,7 @@ var require_discriminator = __commonJS((exports) => {
6104
6104
  exports.default = def;
6105
6105
  });
6106
6106
 
6107
- // node_modules/ajv/dist/refs/json-schema-draft-07.json
6107
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-draft-07.json
6108
6108
  var require_json_schema_draft_07 = __commonJS((exports, module) => {
6109
6109
  module.exports = {
6110
6110
  $schema: "http://json-schema.org/draft-07/schema#",
@@ -6259,7 +6259,7 @@ var require_json_schema_draft_07 = __commonJS((exports, module) => {
6259
6259
  };
6260
6260
  });
6261
6261
 
6262
- // node_modules/ajv/dist/ajv.js
6262
+ // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/ajv.js
6263
6263
  var require_ajv = __commonJS((exports, module) => {
6264
6264
  Object.defineProperty(exports, "__esModule", { value: true });
6265
6265
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = undefined;
@@ -6327,7 +6327,7 @@ var require_ajv = __commonJS((exports, module) => {
6327
6327
  } });
6328
6328
  });
6329
6329
 
6330
- // node_modules/ajv-formats/dist/formats.js
6330
+ // node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.20.0/node_modules/ajv-formats/dist/formats.js
6331
6331
  var require_formats = __commonJS((exports) => {
6332
6332
  Object.defineProperty(exports, "__esModule", { value: true });
6333
6333
  exports.formatNames = exports.fastFormats = exports.fullFormats = undefined;
@@ -6504,7 +6504,7 @@ var require_formats = __commonJS((exports) => {
6504
6504
  }
6505
6505
  });
6506
6506
 
6507
- // node_modules/ajv-formats/dist/limit.js
6507
+ // node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.20.0/node_modules/ajv-formats/dist/limit.js
6508
6508
  var require_limit = __commonJS((exports) => {
6509
6509
  Object.defineProperty(exports, "__esModule", { value: true });
6510
6510
  exports.formatLimitDefinition = undefined;
@@ -6573,7 +6573,7 @@ var require_limit = __commonJS((exports) => {
6573
6573
  exports.default = formatLimitPlugin;
6574
6574
  });
6575
6575
 
6576
- // node_modules/ajv-formats/dist/index.js
6576
+ // node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.20.0/node_modules/ajv-formats/dist/index.js
6577
6577
  var require_dist = __commonJS((exports, module) => {
6578
6578
  Object.defineProperty(exports, "__esModule", { value: true });
6579
6579
  var formats_1 = require_formats();
@@ -6652,43 +6652,169 @@ class SqliteAdapter {
6652
6652
  }
6653
6653
  var init_sqlite_adapter = () => {};
6654
6654
 
6655
- // src/db/paths.ts
6656
- import { chmodSync, copyFileSync, existsSync as existsSync2, mkdirSync, readdirSync, statSync } from "fs";
6655
+ // node_modules/.pnpm/@hasna+paths@0.2.2/node_modules/@hasna/paths/dist/index.js
6656
+ import { homedir as homedir2 } from "os";
6657
6657
  import { join as join2 } from "path";
6658
+ function assertApp(app) {
6659
+ if (typeof app !== "string" || app.length === 0) {
6660
+ throw new TypeError("paths: app must be a non-empty string");
6661
+ }
6662
+ if (!APP_SLUG_RE.test(app)) {
6663
+ throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
6664
+ }
6665
+ }
6666
+ function assertKind(kind) {
6667
+ if (!PATH_KINDS.includes(kind)) {
6668
+ throw new TypeError(`paths: invalid path kind "${kind}" \u2014 expected one of ${PATH_KINDS.join(", ")}`);
6669
+ }
6670
+ }
6671
+ function envOf(options) {
6672
+ return options.env ?? process.env;
6673
+ }
6674
+ function envValue(options, kind) {
6675
+ const value = envOf(options)[KIND_ENV[kind]];
6676
+ return typeof value === "string" && value.length > 0 ? value : undefined;
6677
+ }
6678
+ function isMacOS(platform) {
6679
+ return platform === "darwin";
6680
+ }
6681
+ function baseDir(kind, options) {
6682
+ assertKind(kind);
6683
+ const override = envValue(options, kind);
6684
+ if (override)
6685
+ return override;
6686
+ const home = options.home ?? homedir2();
6687
+ const platform = options.platform ?? process.platform;
6688
+ if (isMacOS(platform)) {
6689
+ switch (kind) {
6690
+ case "config":
6691
+ case "data":
6692
+ return join2(home, "Library", "Application Support", "Hasna");
6693
+ case "cache":
6694
+ return join2(home, "Library", "Caches", "Hasna");
6695
+ case "state":
6696
+ return join2(home, "Library", "Logs", "Hasna");
6697
+ }
6698
+ }
6699
+ switch (kind) {
6700
+ case "config":
6701
+ return join2(home, ".config", "hasna");
6702
+ case "data":
6703
+ return join2(home, ".local", "share", "hasna");
6704
+ case "state":
6705
+ return join2(home, ".local", "state", "hasna");
6706
+ case "cache":
6707
+ return join2(home, ".cache", "hasna");
6708
+ }
6709
+ }
6710
+ function resolvePath(kind, options) {
6711
+ assertKind(kind);
6712
+ assertApp(options.app);
6713
+ const appSegment = options.internal === true ? join2("internal", options.app) : options.app;
6714
+ return join2(baseDir(kind, options), appSegment);
6715
+ }
6716
+ function dataDir(options) {
6717
+ return resolvePath("data", options);
6718
+ }
6719
+ function stateDir(options) {
6720
+ return resolvePath("state", options);
6721
+ }
6722
+ var PATH_KINDS, KIND_ENV, APP_SLUG_RE;
6723
+ var init_dist = __esm(() => {
6724
+ PATH_KINDS = ["config", "data", "state", "cache"];
6725
+ KIND_ENV = {
6726
+ config: "HASNA_CONFIG_HOME",
6727
+ data: "HASNA_DATA_HOME",
6728
+ state: "HASNA_STATE_HOME",
6729
+ cache: "HASNA_CACHE_HOME"
6730
+ };
6731
+ APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
6732
+ });
6733
+
6734
+ // src/db/paths.ts
6735
+ import { chmodSync, copyFileSync, cpSync, existsSync as existsSync2, mkdirSync, readdirSync, statSync } from "fs";
6736
+ import { homedir as homedir3 } from "os";
6737
+ import { join as join3 } from "path";
6658
6738
  function ensurePrivateDir(dir) {
6659
6739
  if (!existsSync2(dir))
6660
6740
  mkdirSync(dir, { recursive: true, mode: 448 });
6661
6741
  chmodSync(dir, 448);
6662
6742
  }
6743
+ function home() {
6744
+ return process.env["HOME"] || process.env["USERPROFILE"] || homedir3();
6745
+ }
6746
+ function hasContent(dir) {
6747
+ if (!existsSync2(dir))
6748
+ return false;
6749
+ try {
6750
+ return readdirSync(dir).length > 0;
6751
+ } catch {
6752
+ return false;
6753
+ }
6754
+ }
6755
+ function adoptLegacy(source, target) {
6756
+ if (!hasContent(source) || hasContent(target))
6757
+ return;
6758
+ ensurePrivateDir(target);
6759
+ for (const entry of readdirSync(source)) {
6760
+ if (entry === ".vault-session")
6761
+ continue;
6762
+ if (entry === "{backups,images,documents}")
6763
+ continue;
6764
+ const oldPath = join3(source, entry);
6765
+ const newPath = join3(target, entry);
6766
+ const st = statSync(oldPath);
6767
+ if (st.isDirectory()) {
6768
+ cpSync(oldPath, newPath, { recursive: true });
6769
+ chmodSync(newPath, 448);
6770
+ } else if (st.isFile()) {
6771
+ copyFileSync(oldPath, newPath);
6772
+ chmodSync(newPath, 384);
6773
+ }
6774
+ }
6775
+ }
6663
6776
  function getDataDir() {
6664
- const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
6665
- const hasnaDir = join2(home, ".hasna");
6666
- const newDir = join2(home, ".hasna", "contacts");
6667
- const oldDir = join2(home, ".contacts");
6668
- if (existsSync2(oldDir) && !existsSync2(newDir)) {
6669
- ensurePrivateDir(hasnaDir);
6670
- ensurePrivateDir(newDir);
6671
- for (const file of readdirSync(oldDir)) {
6672
- const oldPath = join2(oldDir, file);
6673
- if (statSync(oldPath).isFile()) {
6674
- const newPath = join2(newDir, file);
6675
- copyFileSync(oldPath, newPath);
6676
- chmodSync(newPath, 384);
6677
- }
6678
- }
6679
- }
6680
- ensurePrivateDir(hasnaDir);
6681
- ensurePrivateDir(newDir);
6682
- return newDir;
6777
+ const base = home();
6778
+ const target = dataDir({ app: "contacts", home: base });
6779
+ if (!checkedDataTargets.has(target)) {
6780
+ adoptLegacy(join3(base, ".hasna", "contacts"), target);
6781
+ adoptLegacy(join3(base, ".contacts"), target);
6782
+ checkedDataTargets.add(target);
6783
+ }
6784
+ ensurePrivateDir(target);
6785
+ return target;
6786
+ }
6787
+ function getStateDir() {
6788
+ const base = home();
6789
+ const target = stateDir({ app: "contacts", home: base });
6790
+ if (!checkedStateTargets.has(target)) {
6791
+ if (!hasContent(target)) {
6792
+ const legacySession = join3(base, ".hasna", "contacts", ".vault-session");
6793
+ if (existsSync2(legacySession)) {
6794
+ ensurePrivateDir(target);
6795
+ const targetSession = join3(target, ".vault-session");
6796
+ copyFileSync(legacySession, targetSession);
6797
+ chmodSync(targetSession, 384);
6798
+ }
6799
+ }
6800
+ checkedStateTargets.add(target);
6801
+ }
6802
+ ensurePrivateDir(target);
6803
+ return target;
6683
6804
  }
6684
6805
  function getDbPath() {
6685
6806
  if (process.env["HASNA_CONTACTS_DB_PATH"])
6686
6807
  return process.env["HASNA_CONTACTS_DB_PATH"];
6687
6808
  if (process.env["CONTACTS_DB_PATH"])
6688
6809
  return process.env["CONTACTS_DB_PATH"];
6689
- return join2(getDataDir(), "contacts.db");
6810
+ return join3(getDataDir(), "contacts.db");
6690
6811
  }
6691
- var init_paths = () => {};
6812
+ var checkedDataTargets, checkedStateTargets;
6813
+ var init_paths = __esm(() => {
6814
+ init_dist();
6815
+ checkedDataTargets = new Set;
6816
+ checkedStateTargets = new Set;
6817
+ });
6692
6818
 
6693
6819
  // src/db/database.ts
6694
6820
  var exports_database = {};
@@ -6696,6 +6822,7 @@ __export(exports_database, {
6696
6822
  uuid: () => uuid2,
6697
6823
  resetDatabase: () => resetDatabase,
6698
6824
  now: () => now,
6825
+ getStateDir: () => getStateDir,
6699
6826
  getDbPath: () => getDbPath,
6700
6827
  getDatabase: () => getDatabase,
6701
6828
  getDataDir: () => getDataDir
@@ -6741,7 +6868,10 @@ function uuid2() {
6741
6868
  return crypto.randomUUID();
6742
6869
  }
6743
6870
  function now() {
6744
- return new Date().toISOString();
6871
+ const currentMs = Date.now();
6872
+ const nextMs = currentMs > lastNowMs ? currentMs : lastNowMs + 1;
6873
+ lastNowMs = nextMs;
6874
+ return new Date(nextMs).toISOString();
6745
6875
  }
6746
6876
  function quoteIdentifier(identifier) {
6747
6877
  return `"${identifier.replaceAll('"', '""')}"`;
@@ -6779,7 +6909,7 @@ function runMigrations(db) {
6779
6909
  db.exec(`INSERT OR REPLACE INTO _migrations(version) VALUES(${i})`);
6780
6910
  }
6781
6911
  }
6782
- var MIGRATIONS, _db = null;
6912
+ var MIGRATIONS, _db = null, lastNowMs = 0;
6783
6913
  var init_database = __esm(() => {
6784
6914
  init_sqlite_adapter();
6785
6915
  init_paths();
@@ -7351,6 +7481,81 @@ var init_database = __esm(() => {
7351
7481
  );
7352
7482
 
7353
7483
  CREATE INDEX IF NOT EXISTS idx_contacts_tombstones_deleted_at ON _contacts_tombstones(deleted_at);
7484
+ `,
7485
+ `
7486
+ CREATE TABLE IF NOT EXISTS contact_project_membership_states (
7487
+ contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
7488
+ project_id TEXT NOT NULL,
7489
+ linked INTEGER NOT NULL CHECK(linked IN (0, 1)),
7490
+ revision INTEGER NOT NULL DEFAULT 0 CHECK(revision >= 0),
7491
+ updated_at TEXT NOT NULL,
7492
+ PRIMARY KEY (contact_id, project_id)
7493
+ );
7494
+
7495
+ INSERT OR IGNORE INTO contact_project_membership_states
7496
+ (contact_id, project_id, linked, revision, updated_at)
7497
+ SELECT contact_id, project_id, 1, 0, datetime('now')
7498
+ FROM contact_projects;
7499
+
7500
+ CREATE TABLE IF NOT EXISTS contact_project_membership_receipts (
7501
+ receipt_id TEXT PRIMARY KEY,
7502
+ direction TEXT NOT NULL CHECK(direction IN ('attach', 'detach')),
7503
+ contact_id TEXT NOT NULL REFERENCES contacts(id) ON DELETE CASCADE,
7504
+ project_id TEXT NOT NULL,
7505
+ operation_id TEXT NOT NULL,
7506
+ step_id TEXT NOT NULL,
7507
+ expected_version TEXT NOT NULL,
7508
+ before_json TEXT NOT NULL,
7509
+ after_json TEXT NOT NULL,
7510
+ created_at TEXT NOT NULL,
7511
+ UNIQUE(operation_id, step_id)
7512
+ );
7513
+
7514
+ CREATE INDEX IF NOT EXISTS idx_contact_project_membership_states_project
7515
+ ON contact_project_membership_states(project_id, linked, contact_id);
7516
+ CREATE INDEX IF NOT EXISTS idx_contact_project_membership_receipts_target
7517
+ ON contact_project_membership_receipts(contact_id, project_id, created_at);
7518
+
7519
+ CREATE TRIGGER IF NOT EXISTS sync_contact_project_membership_state_after_insert
7520
+ AFTER INSERT ON contact_projects
7521
+ BEGIN
7522
+ INSERT INTO contact_project_membership_states
7523
+ (contact_id, project_id, linked, revision, updated_at)
7524
+ VALUES (NEW.contact_id, NEW.project_id, 1, 1, datetime('now'))
7525
+ ON CONFLICT(contact_id, project_id) DO UPDATE SET
7526
+ linked = 1,
7527
+ revision = CASE
7528
+ WHEN contact_project_membership_states.linked = 1
7529
+ THEN contact_project_membership_states.revision
7530
+ ELSE contact_project_membership_states.revision + 1
7531
+ END,
7532
+ updated_at = CASE
7533
+ WHEN contact_project_membership_states.linked = 1
7534
+ THEN contact_project_membership_states.updated_at
7535
+ ELSE datetime('now')
7536
+ END;
7537
+ END;
7538
+
7539
+ CREATE TRIGGER IF NOT EXISTS sync_contact_project_membership_state_after_delete
7540
+ AFTER DELETE ON contact_projects
7541
+ WHEN EXISTS (SELECT 1 FROM contacts WHERE id = OLD.contact_id)
7542
+ BEGIN
7543
+ INSERT INTO contact_project_membership_states
7544
+ (contact_id, project_id, linked, revision, updated_at)
7545
+ VALUES (OLD.contact_id, OLD.project_id, 0, 1, datetime('now'))
7546
+ ON CONFLICT(contact_id, project_id) DO UPDATE SET
7547
+ linked = 0,
7548
+ revision = CASE
7549
+ WHEN contact_project_membership_states.linked = 0
7550
+ THEN contact_project_membership_states.revision
7551
+ ELSE contact_project_membership_states.revision + 1
7552
+ END,
7553
+ updated_at = CASE
7554
+ WHEN contact_project_membership_states.linked = 0
7555
+ THEN contact_project_membership_states.updated_at
7556
+ ELSE datetime('now')
7557
+ END;
7558
+ END;
7354
7559
  `
7355
7560
  ];
7356
7561
  });
@@ -7448,6 +7653,219 @@ var init_tombstones = __esm(() => {
7448
7653
  init_database();
7449
7654
  });
7450
7655
 
7656
+ // src/types/project-memberships.ts
7657
+ var ContactProjectMembershipConflictError;
7658
+ var init_project_memberships = __esm(() => {
7659
+ ContactProjectMembershipConflictError = class ContactProjectMembershipConflictError extends Error {
7660
+ constructor(message) {
7661
+ super(message);
7662
+ this.name = "ContactProjectMembershipConflictError";
7663
+ }
7664
+ };
7665
+ });
7666
+
7667
+ // src/db/project-memberships.ts
7668
+ import { createHash } from "crypto";
7669
+ function digest(value) {
7670
+ return createHash("sha256").update(value).digest("hex");
7671
+ }
7672
+ function membershipVersion(contactId, projectId, linked, revision) {
7673
+ return `cpmv_${digest(JSON.stringify([contactId, projectId, linked, revision])).slice(0, 32)}`;
7674
+ }
7675
+ function receiptId(input) {
7676
+ return `cpmr_${digest(JSON.stringify([
7677
+ input.operation_id,
7678
+ input.step_id,
7679
+ input.contact_id,
7680
+ input.project_id
7681
+ ])).slice(0, 32)}`;
7682
+ }
7683
+ function stateRow(contactId, projectId, db) {
7684
+ const persisted = db.query(`SELECT contact_id, project_id, linked, revision
7685
+ FROM contact_project_membership_states
7686
+ WHERE contact_id = ? AND project_id = ?`).get(contactId, projectId);
7687
+ if (persisted)
7688
+ return persisted;
7689
+ const linked = Boolean(db.query(`SELECT 1 AS present FROM contact_projects WHERE contact_id = ? AND project_id = ?`).get(contactId, projectId));
7690
+ return { contact_id: contactId, project_id: projectId, linked: linked ? 1 : 0, revision: 0 };
7691
+ }
7692
+ function snapshot(row) {
7693
+ const linked = Boolean(row.linked);
7694
+ return {
7695
+ contact_id: row.contact_id,
7696
+ project_id: row.project_id,
7697
+ linked,
7698
+ version: membershipVersion(row.contact_id, row.project_id, linked, row.revision)
7699
+ };
7700
+ }
7701
+ function required2(value, name) {
7702
+ const normalized = value.trim();
7703
+ if (!normalized)
7704
+ throw new Error(`${name} is required`);
7705
+ return normalized;
7706
+ }
7707
+ function normalizeInput(input) {
7708
+ return {
7709
+ contact_id: required2(input.contact_id, "contact_id"),
7710
+ project_id: required2(input.project_id, "project_id"),
7711
+ operation_id: required2(input.operation_id, "operation_id"),
7712
+ step_id: required2(input.step_id, "step_id"),
7713
+ expected_version: required2(input.expected_version, "expected_version")
7714
+ };
7715
+ }
7716
+ function parseSnapshot(value) {
7717
+ return JSON.parse(value);
7718
+ }
7719
+ function replay(row, direction, input) {
7720
+ if (row.direction !== direction || row.contact_id !== input.contact_id || row.project_id !== input.project_id || row.expected_version !== input.expected_version) {
7721
+ throw new ContactProjectMembershipConflictError(`operation_id/step_id already accepted for a different contact-project membership mutation`);
7722
+ }
7723
+ return {
7724
+ outcome: "duplicate_of_accepted",
7725
+ operation_id: row.operation_id,
7726
+ step_id: row.step_id,
7727
+ before: parseSnapshot(row.before_json),
7728
+ after: parseSnapshot(row.after_json),
7729
+ receipt_id: row.receipt_id
7730
+ };
7731
+ }
7732
+ function transitionWithoutReceipt(contactId, projectId, linked, db) {
7733
+ const beforeRow = stateRow(contactId, projectId, db);
7734
+ const changed = Boolean(beforeRow.linked) !== linked;
7735
+ const afterRow = {
7736
+ ...beforeRow,
7737
+ linked: linked ? 1 : 0,
7738
+ revision: changed ? beforeRow.revision + 1 : beforeRow.revision
7739
+ };
7740
+ const changedAt = now();
7741
+ db.run(`INSERT INTO contact_project_membership_states
7742
+ (contact_id, project_id, linked, revision, updated_at)
7743
+ VALUES (?, ?, ?, ?, ?)
7744
+ ON CONFLICT(contact_id, project_id) DO UPDATE SET
7745
+ linked = excluded.linked,
7746
+ revision = excluded.revision,
7747
+ updated_at = excluded.updated_at`, [contactId, projectId, afterRow.linked, afterRow.revision, changedAt]);
7748
+ if (linked) {
7749
+ db.run(`INSERT OR IGNORE INTO contact_projects (contact_id, project_id) VALUES (?, ?)`, [contactId, projectId]);
7750
+ } else {
7751
+ db.run(`DELETE FROM contact_projects WHERE contact_id = ? AND project_id = ?`, [contactId, projectId]);
7752
+ }
7753
+ return changed;
7754
+ }
7755
+ function setContactProjectMembershipWithoutReceipt(contactId, projectId, linked, db = getDatabase()) {
7756
+ const normalizedContactId = required2(contactId, "contact_id");
7757
+ const normalizedProjectId = required2(projectId, "project_id");
7758
+ return db.transaction(() => transitionWithoutReceipt(normalizedContactId, normalizedProjectId, linked, db));
7759
+ }
7760
+ function replaceContactProjectMembershipsWithoutReceipts(contactId, projectIds, db = getDatabase()) {
7761
+ const normalizedContactId = required2(contactId, "contact_id");
7762
+ const normalizedProjectIds = [...new Set(projectIds.map((projectId) => required2(projectId, "project_id")))];
7763
+ return db.transaction(() => {
7764
+ const currentRows = db.query(`SELECT project_id FROM contact_projects WHERE contact_id = ?`).all(normalizedContactId);
7765
+ const desired = new Set(normalizedProjectIds);
7766
+ const population = new Set([...currentRows.map((row) => row.project_id), ...normalizedProjectIds]);
7767
+ for (const projectId of population) {
7768
+ transitionWithoutReceipt(normalizedContactId, projectId, desired.has(projectId), db);
7769
+ }
7770
+ return normalizedProjectIds;
7771
+ });
7772
+ }
7773
+ function readContactProjectMembership(contactId, projectId, db = getDatabase()) {
7774
+ return snapshot(stateRow(required2(contactId, "contact_id"), required2(projectId, "project_id"), db));
7775
+ }
7776
+ function listContactProjectMemberships(projectId, maxItems, db = getDatabase()) {
7777
+ const normalizedProjectId = required2(projectId, "project_id");
7778
+ if (!Number.isInteger(maxItems) || maxItems < 1)
7779
+ throw new Error("max_items must be a positive integer");
7780
+ const rows = db.query(`SELECT cp.contact_id, cp.project_id,
7781
+ COALESCE(state.linked, 1) AS linked,
7782
+ COALESCE(state.revision, 0) AS revision
7783
+ FROM contact_projects cp
7784
+ LEFT JOIN contact_project_membership_states state
7785
+ ON state.contact_id = cp.contact_id AND state.project_id = cp.project_id
7786
+ WHERE cp.project_id = ?
7787
+ ORDER BY cp.contact_id ASC
7788
+ LIMIT ?`).all(normalizedProjectId, maxItems + 1);
7789
+ if (rows.length > maxItems) {
7790
+ throw new Error(`contact project membership collection exceeds max_items=${maxItems}`);
7791
+ }
7792
+ const contactIds = rows.map((row) => row.contact_id);
7793
+ return {
7794
+ project_id: normalizedProjectId,
7795
+ contact_ids: contactIds,
7796
+ complete: true,
7797
+ membership_revision: `cpml_${digest(JSON.stringify(rows.map((row) => snapshot(row)))).slice(0, 32)}`
7798
+ };
7799
+ }
7800
+ function mutateContactProjectMembership(direction, rawInput, db = getDatabase()) {
7801
+ const input = normalizeInput(rawInput);
7802
+ return db.transaction(() => {
7803
+ const existingReceipt = db.query(`SELECT direction, contact_id, project_id, operation_id, step_id, expected_version,
7804
+ before_json, after_json, receipt_id
7805
+ FROM contact_project_membership_receipts
7806
+ WHERE operation_id = ? AND step_id = ?`).get(input.operation_id, input.step_id);
7807
+ if (existingReceipt)
7808
+ return replay(existingReceipt, direction, input);
7809
+ const contact = db.query(`SELECT id FROM contacts WHERE id = ?`).get(input.contact_id);
7810
+ if (!contact)
7811
+ throw new Error(`contact not found: ${input.contact_id}`);
7812
+ const beforeRow = stateRow(input.contact_id, input.project_id, db);
7813
+ const before = snapshot(beforeRow);
7814
+ if (before.version !== input.expected_version) {
7815
+ throw new ContactProjectMembershipConflictError(`contact project membership expected_version conflict: expected ${input.expected_version}, current ${before.version}`);
7816
+ }
7817
+ const desiredLinked = direction === "attach";
7818
+ const changed = before.linked !== desiredLinked;
7819
+ const afterRow = {
7820
+ ...beforeRow,
7821
+ linked: desiredLinked ? 1 : 0,
7822
+ revision: changed ? beforeRow.revision + 1 : beforeRow.revision
7823
+ };
7824
+ const changedAt = now();
7825
+ db.run(`INSERT INTO contact_project_membership_states
7826
+ (contact_id, project_id, linked, revision, updated_at)
7827
+ VALUES (?, ?, ?, ?, ?)
7828
+ ON CONFLICT(contact_id, project_id) DO UPDATE SET
7829
+ linked = excluded.linked,
7830
+ revision = excluded.revision,
7831
+ updated_at = excluded.updated_at`, [input.contact_id, input.project_id, afterRow.linked, afterRow.revision, changedAt]);
7832
+ if (desiredLinked) {
7833
+ db.run(`INSERT OR IGNORE INTO contact_projects (contact_id, project_id) VALUES (?, ?)`, [input.contact_id, input.project_id]);
7834
+ } else {
7835
+ db.run(`DELETE FROM contact_projects WHERE contact_id = ? AND project_id = ?`, [input.contact_id, input.project_id]);
7836
+ }
7837
+ const after = snapshot(afterRow);
7838
+ const id = receiptId(input);
7839
+ db.run(`INSERT INTO contact_project_membership_receipts (
7840
+ receipt_id, direction, contact_id, project_id, operation_id, step_id,
7841
+ expected_version, before_json, after_json, created_at
7842
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
7843
+ id,
7844
+ direction,
7845
+ input.contact_id,
7846
+ input.project_id,
7847
+ input.operation_id,
7848
+ input.step_id,
7849
+ input.expected_version,
7850
+ JSON.stringify(before),
7851
+ JSON.stringify(after),
7852
+ changedAt
7853
+ ]);
7854
+ return {
7855
+ outcome: changed ? "accepted" : "duplicate_of_accepted",
7856
+ operation_id: input.operation_id,
7857
+ step_id: input.step_id,
7858
+ before,
7859
+ after,
7860
+ receipt_id: id
7861
+ };
7862
+ });
7863
+ }
7864
+ var init_project_memberships2 = __esm(() => {
7865
+ init_database();
7866
+ init_project_memberships();
7867
+ });
7868
+
7451
7869
  // src/db/contacts.ts
7452
7870
  var exports_contacts = {};
7453
7871
  __export(exports_contacts, {
@@ -8046,34 +8464,32 @@ function autoLinkContactToCompany(contactId, db) {
8046
8464
  }
8047
8465
  function linkContactToProject(contactId, projectId, db) {
8048
8466
  const d = db || getDatabase();
8049
- d.run(`INSERT OR IGNORE INTO contact_projects (contact_id, project_id) VALUES (?, ?)`, [contactId, projectId]);
8467
+ setContactProjectMembershipWithoutReceipt(contactId, projectId, true, d);
8050
8468
  }
8051
8469
  function unlinkContactFromProject(contactId, projectId, db) {
8052
8470
  const d = db || getDatabase();
8053
- d.run(`DELETE FROM contact_projects WHERE contact_id = ? AND project_id = ?`, [contactId, projectId]);
8471
+ setContactProjectMembershipWithoutReceipt(contactId, projectId, false, d);
8054
8472
  }
8055
8473
  function getContactProjectIds(contactId, db) {
8056
8474
  const d = db || getDatabase();
8057
- const rows = d.query(`SELECT project_id FROM contact_projects WHERE contact_id = ?`).all(contactId);
8475
+ const rows = d.query(`SELECT project_id FROM contact_projects WHERE contact_id = ? ORDER BY project_id ASC`).all(contactId);
8058
8476
  return rows.map((r) => r.project_id);
8059
8477
  }
8060
8478
  function listContactIdsByProject(projectId, db) {
8061
8479
  const d = db || getDatabase();
8062
- const rows = d.query(`SELECT contact_id FROM contact_projects WHERE project_id = ?`).all(projectId);
8480
+ const rows = d.query(`SELECT contact_id FROM contact_projects WHERE project_id = ? ORDER BY contact_id ASC`).all(projectId);
8063
8481
  return rows.map((r) => r.contact_id);
8064
8482
  }
8065
8483
  function setContactProjects(contactId, projectIds, db) {
8066
8484
  const d = db || getDatabase();
8067
- d.run(`DELETE FROM contact_projects WHERE contact_id = ?`, [contactId]);
8068
- for (const pid of projectIds) {
8069
- d.run(`INSERT OR IGNORE INTO contact_projects (contact_id, project_id) VALUES (?, ?)`, [contactId, pid]);
8070
- }
8485
+ replaceContactProjectMembershipsWithoutReceipts(contactId, projectIds, d);
8071
8486
  }
8072
8487
  var init_contacts = __esm(() => {
8073
8488
  init_types();
8074
8489
  init_database();
8075
8490
  init_activity();
8076
8491
  init_tombstones();
8492
+ init_project_memberships2();
8077
8493
  });
8078
8494
 
8079
8495
  // src/db/events.ts
@@ -8166,11 +8582,117 @@ var init_events = __esm(() => {
8166
8582
  init_database();
8167
8583
  });
8168
8584
 
8585
+ // node_modules/.pnpm/content-type@1.0.5/node_modules/content-type/index.js
8586
+ var require_content_type = __commonJS((exports) => {
8587
+ /*!
8588
+ * content-type
8589
+ * Copyright(c) 2015 Douglas Christopher Wilson
8590
+ * MIT Licensed
8591
+ */
8592
+ var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
8593
+ var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
8594
+ var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
8595
+ var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
8596
+ var QUOTE_REGEXP = /([\\"])/g;
8597
+ var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
8598
+ exports.format = format;
8599
+ exports.parse = parse6;
8600
+ function format(obj) {
8601
+ if (!obj || typeof obj !== "object") {
8602
+ throw new TypeError("argument obj is required");
8603
+ }
8604
+ var parameters = obj.parameters;
8605
+ var type = obj.type;
8606
+ if (!type || !TYPE_REGEXP.test(type)) {
8607
+ throw new TypeError("invalid type");
8608
+ }
8609
+ var string4 = type;
8610
+ if (parameters && typeof parameters === "object") {
8611
+ var param;
8612
+ var params = Object.keys(parameters).sort();
8613
+ for (var i = 0;i < params.length; i++) {
8614
+ param = params[i];
8615
+ if (!TOKEN_REGEXP.test(param)) {
8616
+ throw new TypeError("invalid parameter name");
8617
+ }
8618
+ string4 += "; " + param + "=" + qstring(parameters[param]);
8619
+ }
8620
+ }
8621
+ return string4;
8622
+ }
8623
+ function parse6(string4) {
8624
+ if (!string4) {
8625
+ throw new TypeError("argument string is required");
8626
+ }
8627
+ var header = typeof string4 === "object" ? getcontenttype(string4) : string4;
8628
+ if (typeof header !== "string") {
8629
+ throw new TypeError("argument string is required to be a string");
8630
+ }
8631
+ var index = header.indexOf(";");
8632
+ var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
8633
+ if (!TYPE_REGEXP.test(type)) {
8634
+ throw new TypeError("invalid media type");
8635
+ }
8636
+ var obj = new ContentType(type.toLowerCase());
8637
+ if (index !== -1) {
8638
+ var key;
8639
+ var match;
8640
+ var value;
8641
+ PARAM_REGEXP.lastIndex = index;
8642
+ while (match = PARAM_REGEXP.exec(header)) {
8643
+ if (match.index !== index) {
8644
+ throw new TypeError("invalid parameter format");
8645
+ }
8646
+ index += match[0].length;
8647
+ key = match[1].toLowerCase();
8648
+ value = match[2];
8649
+ if (value.charCodeAt(0) === 34) {
8650
+ value = value.slice(1, -1);
8651
+ if (value.indexOf("\\") !== -1) {
8652
+ value = value.replace(QESC_REGEXP, "$1");
8653
+ }
8654
+ }
8655
+ obj.parameters[key] = value;
8656
+ }
8657
+ if (index !== header.length) {
8658
+ throw new TypeError("invalid parameter format");
8659
+ }
8660
+ }
8661
+ return obj;
8662
+ }
8663
+ function getcontenttype(obj) {
8664
+ var header;
8665
+ if (typeof obj.getHeader === "function") {
8666
+ header = obj.getHeader("content-type");
8667
+ } else if (typeof obj.headers === "object") {
8668
+ header = obj.headers && obj.headers["content-type"];
8669
+ }
8670
+ if (typeof header !== "string") {
8671
+ throw new TypeError("content-type header is missing from object");
8672
+ }
8673
+ return header;
8674
+ }
8675
+ function qstring(val) {
8676
+ var str = String(val);
8677
+ if (TOKEN_REGEXP.test(str)) {
8678
+ return str;
8679
+ }
8680
+ if (str.length > 0 && !TEXT_REGEXP.test(str)) {
8681
+ throw new TypeError("invalid parameter value");
8682
+ }
8683
+ return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
8684
+ }
8685
+ function ContentType(type) {
8686
+ this.parameters = Object.create(null);
8687
+ this.type = type;
8688
+ }
8689
+ });
8690
+
8169
8691
  // src/mcp/index.ts
8170
8692
  import { readFileSync as readFileSync5 } from "fs";
8171
- import { join as join5 } from "path";
8693
+ import { join as join7 } from "path";
8172
8694
 
8173
- // node_modules/zod/v3/external.js
8695
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
8174
8696
  var exports_external = {};
8175
8697
  __export(exports_external, {
8176
8698
  void: () => voidType,
@@ -8282,7 +8804,7 @@ __export(exports_external, {
8282
8804
  BRAND: () => BRAND
8283
8805
  });
8284
8806
 
8285
- // node_modules/zod/v3/helpers/util.js
8807
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
8286
8808
  var util;
8287
8809
  (function(util2) {
8288
8810
  util2.assertEqual = (_) => {};
@@ -8413,7 +8935,7 @@ var getParsedType = (data) => {
8413
8935
  }
8414
8936
  };
8415
8937
 
8416
- // node_modules/zod/v3/ZodError.js
8938
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
8417
8939
  var ZodIssueCode = util.arrayToEnum([
8418
8940
  "invalid_type",
8419
8941
  "invalid_literal",
@@ -8532,7 +9054,7 @@ ZodError.create = (issues) => {
8532
9054
  return error;
8533
9055
  };
8534
9056
 
8535
- // node_modules/zod/v3/locales/en.js
9057
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
8536
9058
  var errorMap = (issue, _ctx) => {
8537
9059
  let message;
8538
9060
  switch (issue.code) {
@@ -8635,7 +9157,7 @@ var errorMap = (issue, _ctx) => {
8635
9157
  };
8636
9158
  var en_default = errorMap;
8637
9159
 
8638
- // node_modules/zod/v3/errors.js
9160
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
8639
9161
  var overrideErrorMap = en_default;
8640
9162
  function setErrorMap(map) {
8641
9163
  overrideErrorMap = map;
@@ -8643,7 +9165,7 @@ function setErrorMap(map) {
8643
9165
  function getErrorMap() {
8644
9166
  return overrideErrorMap;
8645
9167
  }
8646
- // node_modules/zod/v3/helpers/parseUtil.js
9168
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
8647
9169
  var makeIssue = (params) => {
8648
9170
  const { data, path, errorMaps, issueData } = params;
8649
9171
  const fullPath = [...path, ...issueData.path || []];
@@ -8749,14 +9271,14 @@ var isAborted = (x) => x.status === "aborted";
8749
9271
  var isDirty = (x) => x.status === "dirty";
8750
9272
  var isValid = (x) => x.status === "valid";
8751
9273
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
8752
- // node_modules/zod/v3/helpers/errorUtil.js
9274
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
8753
9275
  var errorUtil;
8754
9276
  (function(errorUtil2) {
8755
9277
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
8756
9278
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
8757
9279
  })(errorUtil || (errorUtil = {}));
8758
9280
 
8759
- // node_modules/zod/v3/types.js
9281
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
8760
9282
  class ParseInputLazyPath {
8761
9283
  constructor(parent, value, path, key) {
8762
9284
  this._cachedPath = [];
@@ -12143,7 +12665,7 @@ var coerce = {
12143
12665
  date: (arg) => ZodDate.create({ ...arg, coerce: true })
12144
12666
  };
12145
12667
  var NEVER = INVALID;
12146
- // node_modules/zod/v4/core/core.js
12668
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
12147
12669
  var NEVER2 = Object.freeze({
12148
12670
  status: "aborted"
12149
12671
  });
@@ -12203,7 +12725,7 @@ function config(newConfig) {
12203
12725
  Object.assign(globalConfig, newConfig);
12204
12726
  return globalConfig;
12205
12727
  }
12206
- // node_modules/zod/v4/core/util.js
12728
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/util.js
12207
12729
  var exports_util = {};
12208
12730
  __export(exports_util, {
12209
12731
  unwrapMessage: () => unwrapMessage,
@@ -12717,7 +13239,7 @@ class Class {
12717
13239
  constructor(..._args) {}
12718
13240
  }
12719
13241
 
12720
- // node_modules/zod/v4/core/errors.js
13242
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/errors.js
12721
13243
  var initializer = (inst, def) => {
12722
13244
  inst.name = "$ZodError";
12723
13245
  Object.defineProperty(inst, "_zod", {
@@ -12791,7 +13313,7 @@ function formatError(error, _mapper) {
12791
13313
  return fieldErrors;
12792
13314
  }
12793
13315
 
12794
- // node_modules/zod/v4/core/parse.js
13316
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/parse.js
12795
13317
  var _parse = (_Err) => (schema, value, _ctx, _params) => {
12796
13318
  const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
12797
13319
  const result = schema._zod.run({ value, issues: [] }, ctx);
@@ -12842,7 +13364,7 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
12842
13364
  } : { success: true, data: result.value };
12843
13365
  };
12844
13366
  var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
12845
- // node_modules/zod/v4/core/regexes.js
13367
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/regexes.js
12846
13368
  var cuid = /^[cC][^\s-]{8,}$/;
12847
13369
  var cuid2 = /^[0-9a-z]+$/;
12848
13370
  var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
@@ -12900,7 +13422,7 @@ var _null = /null/i;
12900
13422
  var lowercase = /^[^A-Z]*$/;
12901
13423
  var uppercase = /^[^a-z]*$/;
12902
13424
 
12903
- // node_modules/zod/v4/core/checks.js
13425
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/checks.js
12904
13426
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
12905
13427
  var _a;
12906
13428
  inst._zod ?? (inst._zod = {});
@@ -13284,7 +13806,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
13284
13806
  };
13285
13807
  });
13286
13808
 
13287
- // node_modules/zod/v4/core/doc.js
13809
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/doc.js
13288
13810
  class Doc {
13289
13811
  constructor(args = []) {
13290
13812
  this.content = [];
@@ -13322,14 +13844,14 @@ class Doc {
13322
13844
  }
13323
13845
  }
13324
13846
 
13325
- // node_modules/zod/v4/core/versions.js
13847
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/versions.js
13326
13848
  var version = {
13327
13849
  major: 4,
13328
13850
  minor: 0,
13329
13851
  patch: 0
13330
13852
  };
13331
13853
 
13332
- // node_modules/zod/v4/core/schemas.js
13854
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/schemas.js
13333
13855
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
13334
13856
  var _a;
13335
13857
  inst ?? (inst = {});
@@ -14560,7 +15082,7 @@ function handleRefineResult(result, payload, input, inst) {
14560
15082
  payload.issues.push(issue(_iss));
14561
15083
  }
14562
15084
  }
14563
- // node_modules/zod/v4/locales/en.js
15085
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/locales/en.js
14564
15086
  var parsedType = (data) => {
14565
15087
  const t = typeof data;
14566
15088
  switch (t) {
@@ -14677,7 +15199,7 @@ function en_default2() {
14677
15199
  localeError: error()
14678
15200
  };
14679
15201
  }
14680
- // node_modules/zod/v4/core/registries.js
15202
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/registries.js
14681
15203
  var $output = Symbol("ZodOutput");
14682
15204
  var $input = Symbol("ZodInput");
14683
15205
 
@@ -14727,7 +15249,7 @@ function registry() {
14727
15249
  return new $ZodRegistry;
14728
15250
  }
14729
15251
  var globalRegistry = /* @__PURE__ */ registry();
14730
- // node_modules/zod/v4/core/api.js
15252
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/api.js
14731
15253
  function _string(Class2, params) {
14732
15254
  return new Class2({
14733
15255
  type: "string",
@@ -15162,7 +15684,7 @@ function _refine(Class2, fn, _params) {
15162
15684
  });
15163
15685
  return schema;
15164
15686
  }
15165
- // node_modules/zod/v4/core/to-json-schema.js
15687
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/to-json-schema.js
15166
15688
  class JSONSchemaGenerator {
15167
15689
  constructor(params) {
15168
15690
  this.counter = 0;
@@ -15914,7 +16436,7 @@ function isTransforming(_schema, _ctx) {
15914
16436
  }
15915
16437
  throw new Error(`Unknown schema type: ${def.type}`);
15916
16438
  }
15917
- // node_modules/zod/v4/mini/schemas.js
16439
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/mini/schemas.js
15918
16440
  var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
15919
16441
  if (!inst._zod)
15920
16442
  throw new Error("Uninitialized schema in ZodMiniType.");
@@ -15956,7 +16478,7 @@ function object(shape, params) {
15956
16478
  };
15957
16479
  return new ZodMiniObject(def);
15958
16480
  }
15959
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
16481
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
15960
16482
  function isZ4Schema(s) {
15961
16483
  const schema = s;
15962
16484
  return !!schema._zod;
@@ -16040,17 +16562,34 @@ function normalizeObjectSchema(schema) {
16040
16562
  }
16041
16563
  return;
16042
16564
  }
16565
+ function getDotPath(path) {
16566
+ if (path.length === 0) {
16567
+ return "object root";
16568
+ }
16569
+ return path.reduce((acc, seg, index) => {
16570
+ if (index === 0) {
16571
+ return String(seg);
16572
+ }
16573
+ if (typeof seg === "number") {
16574
+ return `${acc}[${seg}]`;
16575
+ }
16576
+ return `${acc}.${seg}`;
16577
+ }, "");
16578
+ }
16043
16579
  function getParseErrorMessage(error2) {
16044
16580
  if (error2 && typeof error2 === "object") {
16581
+ if ("issues" in error2 && Array.isArray(error2.issues) && error2.issues.length > 0) {
16582
+ return error2.issues.map((i) => {
16583
+ if (!i.path?.length) {
16584
+ return i.message;
16585
+ }
16586
+ return `${i.message} at ${getDotPath(i.path)}`;
16587
+ }).join(`
16588
+ `);
16589
+ }
16045
16590
  if ("message" in error2 && typeof error2.message === "string") {
16046
16591
  return error2.message;
16047
16592
  }
16048
- if ("issues" in error2 && Array.isArray(error2.issues) && error2.issues.length > 0) {
16049
- const firstIssue = error2.issues[0];
16050
- if (firstIssue && typeof firstIssue === "object" && "message" in firstIssue) {
16051
- return String(firstIssue.message);
16052
- }
16053
- }
16054
16593
  try {
16055
16594
  return JSON.stringify(error2);
16056
16595
  } catch {
@@ -16099,7 +16638,7 @@ function getLiteralValue(schema) {
16099
16638
  return directValue;
16100
16639
  return;
16101
16640
  }
16102
- // node_modules/zod/v4/classic/iso.js
16641
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/iso.js
16103
16642
  var exports_iso2 = {};
16104
16643
  __export(exports_iso2, {
16105
16644
  time: () => time2,
@@ -16140,7 +16679,7 @@ function duration2(params) {
16140
16679
  return _isoDuration(ZodISODuration, params);
16141
16680
  }
16142
16681
 
16143
- // node_modules/zod/v4/classic/errors.js
16682
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/errors.js
16144
16683
  var initializer2 = (inst, issues) => {
16145
16684
  $ZodError.init(inst, issues);
16146
16685
  inst.name = "ZodError";
@@ -16169,13 +16708,13 @@ var ZodRealError = $constructor("ZodError", initializer2, {
16169
16708
  Parent: Error
16170
16709
  });
16171
16710
 
16172
- // node_modules/zod/v4/classic/parse.js
16711
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/parse.js
16173
16712
  var parse4 = /* @__PURE__ */ _parse(ZodRealError);
16174
16713
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
16175
16714
  var safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
16176
16715
  var safeParseAsync3 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
16177
16716
 
16178
- // node_modules/zod/v4/classic/schemas.js
16717
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/schemas.js
16179
16718
  var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
16180
16719
  $ZodType.init(inst, def);
16181
16720
  inst.def = def;
@@ -16780,10 +17319,10 @@ function superRefine(fn) {
16780
17319
  function preprocess(fn, schema) {
16781
17320
  return pipe(transform(fn), schema);
16782
17321
  }
16783
- // node_modules/zod/v4/classic/external.js
17322
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/external.js
16784
17323
  config(en_default2());
16785
17324
 
16786
- // node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
17325
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
16787
17326
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
16788
17327
  var DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
16789
17328
  var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
@@ -16793,7 +17332,7 @@ var AssertObjectSchema = custom2((v) => v !== null && (typeof v === "object" ||
16793
17332
  var ProgressTokenSchema = union([string2(), number2().int()]);
16794
17333
  var CursorSchema = string2();
16795
17334
  var TaskCreationParamsSchema = looseObject({
16796
- ttl: union([number2(), _null3()]).optional(),
17335
+ ttl: number2().optional(),
16797
17336
  pollInterval: number2().optional()
16798
17337
  });
16799
17338
  var TaskMetadataSchema = object2({
@@ -16947,7 +17486,8 @@ var ClientCapabilitiesSchema = object2({
16947
17486
  roots: object2({
16948
17487
  listChanged: boolean2().optional()
16949
17488
  }).optional(),
16950
- tasks: ClientTasksCapabilitySchema.optional()
17489
+ tasks: ClientTasksCapabilitySchema.optional(),
17490
+ extensions: record(string2(), AssertObjectSchema).optional()
16951
17491
  });
16952
17492
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
16953
17493
  protocolVersion: string2(),
@@ -16973,7 +17513,8 @@ var ServerCapabilitiesSchema = object2({
16973
17513
  tools: object2({
16974
17514
  listChanged: boolean2().optional()
16975
17515
  }).optional(),
16976
- tasks: ServerTasksCapabilitySchema.optional()
17516
+ tasks: ServerTasksCapabilitySchema.optional(),
17517
+ extensions: record(string2(), AssertObjectSchema).optional()
16977
17518
  });
16978
17519
  var InitializeResultSchema = ResultSchema.extend({
16979
17520
  protocolVersion: string2(),
@@ -17088,6 +17629,7 @@ var ResourceSchema = object2({
17088
17629
  uri: string2(),
17089
17630
  description: optional(string2()),
17090
17631
  mimeType: optional(string2()),
17632
+ size: optional(number2()),
17091
17633
  annotations: AnnotationsSchema.optional(),
17092
17634
  _meta: optional(looseObject({}))
17093
17635
  });
@@ -17627,12 +18169,12 @@ class UrlElicitationRequiredError extends McpError {
17627
18169
  }
17628
18170
  }
17629
18171
 
17630
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
18172
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
17631
18173
  function isTerminal(status) {
17632
18174
  return status === "completed" || status === "failed" || status === "cancelled";
17633
18175
  }
17634
18176
 
17635
- // node_modules/zod-to-json-schema/dist/esm/Options.js
18177
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js
17636
18178
  var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
17637
18179
  var defaultOptions = {
17638
18180
  name: undefined,
@@ -17665,7 +18207,7 @@ var getDefaultOptions = (options) => typeof options === "string" ? {
17665
18207
  ...defaultOptions,
17666
18208
  ...options
17667
18209
  };
17668
- // node_modules/zod-to-json-schema/dist/esm/Refs.js
18210
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js
17669
18211
  var getRefs = (options) => {
17670
18212
  const _options = getDefaultOptions(options);
17671
18213
  const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
@@ -17684,7 +18226,7 @@ var getRefs = (options) => {
17684
18226
  ]))
17685
18227
  };
17686
18228
  };
17687
- // node_modules/zod-to-json-schema/dist/esm/errorMessages.js
18229
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
17688
18230
  function addErrorMessage(res, key, errorMessage, refs) {
17689
18231
  if (!refs?.errorMessages)
17690
18232
  return;
@@ -17699,7 +18241,7 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
17699
18241
  res[key] = value;
17700
18242
  addErrorMessage(res, key, errorMessage, refs);
17701
18243
  }
17702
- // node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
18244
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
17703
18245
  var getRelativePath = (pathA, pathB) => {
17704
18246
  let i = 0;
17705
18247
  for (;i < pathA.length && i < pathB.length; i++) {
@@ -17708,7 +18250,7 @@ var getRelativePath = (pathA, pathB) => {
17708
18250
  }
17709
18251
  return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
17710
18252
  };
17711
- // node_modules/zod-to-json-schema/dist/esm/parsers/any.js
18253
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
17712
18254
  function parseAnyDef(refs) {
17713
18255
  if (refs.target !== "openAi") {
17714
18256
  return {};
@@ -17724,7 +18266,7 @@ function parseAnyDef(refs) {
17724
18266
  };
17725
18267
  }
17726
18268
 
17727
- // node_modules/zod-to-json-schema/dist/esm/parsers/array.js
18269
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
17728
18270
  function parseArrayDef(def, refs) {
17729
18271
  const res = {
17730
18272
  type: "array"
@@ -17748,7 +18290,7 @@ function parseArrayDef(def, refs) {
17748
18290
  return res;
17749
18291
  }
17750
18292
 
17751
- // node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
18293
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
17752
18294
  function parseBigintDef(def, refs) {
17753
18295
  const res = {
17754
18296
  type: "integer",
@@ -17794,24 +18336,24 @@ function parseBigintDef(def, refs) {
17794
18336
  return res;
17795
18337
  }
17796
18338
 
17797
- // node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
18339
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
17798
18340
  function parseBooleanDef() {
17799
18341
  return {
17800
18342
  type: "boolean"
17801
18343
  };
17802
18344
  }
17803
18345
 
17804
- // node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
18346
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
17805
18347
  function parseBrandedDef(_def, refs) {
17806
18348
  return parseDef(_def.type._def, refs);
17807
18349
  }
17808
18350
 
17809
- // node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
18351
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
17810
18352
  var parseCatchDef = (def, refs) => {
17811
18353
  return parseDef(def.innerType._def, refs);
17812
18354
  };
17813
18355
 
17814
- // node_modules/zod-to-json-schema/dist/esm/parsers/date.js
18356
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
17815
18357
  function parseDateDef(def, refs, overrideDateStrategy) {
17816
18358
  const strategy = overrideDateStrategy ?? refs.dateStrategy;
17817
18359
  if (Array.isArray(strategy)) {
@@ -17856,7 +18398,7 @@ var integerDateParser = (def, refs) => {
17856
18398
  return res;
17857
18399
  };
17858
18400
 
17859
- // node_modules/zod-to-json-schema/dist/esm/parsers/default.js
18401
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
17860
18402
  function parseDefaultDef(_def, refs) {
17861
18403
  return {
17862
18404
  ...parseDef(_def.innerType._def, refs),
@@ -17864,12 +18406,12 @@ function parseDefaultDef(_def, refs) {
17864
18406
  };
17865
18407
  }
17866
18408
 
17867
- // node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
18409
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
17868
18410
  function parseEffectsDef(_def, refs) {
17869
18411
  return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
17870
18412
  }
17871
18413
 
17872
- // node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
18414
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
17873
18415
  function parseEnumDef(def) {
17874
18416
  return {
17875
18417
  type: "string",
@@ -17877,7 +18419,7 @@ function parseEnumDef(def) {
17877
18419
  };
17878
18420
  }
17879
18421
 
17880
- // node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
18422
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
17881
18423
  var isJsonSchema7AllOfType = (type) => {
17882
18424
  if ("type" in type && type.type === "string")
17883
18425
  return false;
@@ -17919,7 +18461,7 @@ function parseIntersectionDef(def, refs) {
17919
18461
  } : undefined;
17920
18462
  }
17921
18463
 
17922
- // node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
18464
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
17923
18465
  function parseLiteralDef(def, refs) {
17924
18466
  const parsedType2 = typeof def.value;
17925
18467
  if (parsedType2 !== "bigint" && parsedType2 !== "number" && parsedType2 !== "boolean" && parsedType2 !== "string") {
@@ -17939,7 +18481,7 @@ function parseLiteralDef(def, refs) {
17939
18481
  };
17940
18482
  }
17941
18483
 
17942
- // node_modules/zod-to-json-schema/dist/esm/parsers/string.js
18484
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
17943
18485
  var emojiRegex2 = undefined;
17944
18486
  var zodPatterns = {
17945
18487
  cuid: /^[cC][^\s-]{8,}$/,
@@ -18236,7 +18778,7 @@ function stringifyRegExpWithFlags(regex, refs) {
18236
18778
  return pattern;
18237
18779
  }
18238
18780
 
18239
- // node_modules/zod-to-json-schema/dist/esm/parsers/record.js
18781
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
18240
18782
  function parseRecordDef(def, refs) {
18241
18783
  if (refs.target === "openAi") {
18242
18784
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
@@ -18288,7 +18830,7 @@ function parseRecordDef(def, refs) {
18288
18830
  return schema;
18289
18831
  }
18290
18832
 
18291
- // node_modules/zod-to-json-schema/dist/esm/parsers/map.js
18833
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
18292
18834
  function parseMapDef(def, refs) {
18293
18835
  if (refs.mapStrategy === "record") {
18294
18836
  return parseRecordDef(def, refs);
@@ -18313,7 +18855,7 @@ function parseMapDef(def, refs) {
18313
18855
  };
18314
18856
  }
18315
18857
 
18316
- // node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
18858
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
18317
18859
  function parseNativeEnumDef(def) {
18318
18860
  const object3 = def.values;
18319
18861
  const actualKeys = Object.keys(def.values).filter((key) => {
@@ -18327,7 +18869,7 @@ function parseNativeEnumDef(def) {
18327
18869
  };
18328
18870
  }
18329
18871
 
18330
- // node_modules/zod-to-json-schema/dist/esm/parsers/never.js
18872
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
18331
18873
  function parseNeverDef(refs) {
18332
18874
  return refs.target === "openAi" ? undefined : {
18333
18875
  not: parseAnyDef({
@@ -18337,7 +18879,7 @@ function parseNeverDef(refs) {
18337
18879
  };
18338
18880
  }
18339
18881
 
18340
- // node_modules/zod-to-json-schema/dist/esm/parsers/null.js
18882
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
18341
18883
  function parseNullDef(refs) {
18342
18884
  return refs.target === "openApi3" ? {
18343
18885
  enum: ["null"],
@@ -18347,7 +18889,7 @@ function parseNullDef(refs) {
18347
18889
  };
18348
18890
  }
18349
18891
 
18350
- // node_modules/zod-to-json-schema/dist/esm/parsers/union.js
18892
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
18351
18893
  var primitiveMappings = {
18352
18894
  ZodString: "string",
18353
18895
  ZodNumber: "number",
@@ -18415,7 +18957,7 @@ var asAnyOf = (def, refs) => {
18415
18957
  return anyOf.length ? { anyOf } : undefined;
18416
18958
  };
18417
18959
 
18418
- // node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
18960
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
18419
18961
  function parseNullableDef(def, refs) {
18420
18962
  if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
18421
18963
  if (refs.target === "openApi3") {
@@ -18447,7 +18989,7 @@ function parseNullableDef(def, refs) {
18447
18989
  return base && { anyOf: [base, { type: "null" }] };
18448
18990
  }
18449
18991
 
18450
- // node_modules/zod-to-json-schema/dist/esm/parsers/number.js
18992
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
18451
18993
  function parseNumberDef(def, refs) {
18452
18994
  const res = {
18453
18995
  type: "number"
@@ -18496,7 +19038,7 @@ function parseNumberDef(def, refs) {
18496
19038
  return res;
18497
19039
  }
18498
19040
 
18499
- // node_modules/zod-to-json-schema/dist/esm/parsers/object.js
19041
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
18500
19042
  function parseObjectDef(def, refs) {
18501
19043
  const forceOptionalIntoNullable = refs.target === "openAi";
18502
19044
  const result = {
@@ -18566,7 +19108,7 @@ function safeIsOptional(schema) {
18566
19108
  }
18567
19109
  }
18568
19110
 
18569
- // node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
19111
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
18570
19112
  var parseOptionalDef = (def, refs) => {
18571
19113
  if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
18572
19114
  return parseDef(def.innerType._def, refs);
@@ -18585,7 +19127,7 @@ var parseOptionalDef = (def, refs) => {
18585
19127
  } : parseAnyDef(refs);
18586
19128
  };
18587
19129
 
18588
- // node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
19130
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
18589
19131
  var parsePipelineDef = (def, refs) => {
18590
19132
  if (refs.pipeStrategy === "input") {
18591
19133
  return parseDef(def.in._def, refs);
@@ -18605,12 +19147,12 @@ var parsePipelineDef = (def, refs) => {
18605
19147
  };
18606
19148
  };
18607
19149
 
18608
- // node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
19150
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
18609
19151
  function parsePromiseDef(def, refs) {
18610
19152
  return parseDef(def.type._def, refs);
18611
19153
  }
18612
19154
 
18613
- // node_modules/zod-to-json-schema/dist/esm/parsers/set.js
19155
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
18614
19156
  function parseSetDef(def, refs) {
18615
19157
  const items = parseDef(def.valueType._def, {
18616
19158
  ...refs,
@@ -18630,7 +19172,7 @@ function parseSetDef(def, refs) {
18630
19172
  return schema;
18631
19173
  }
18632
19174
 
18633
- // node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
19175
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
18634
19176
  function parseTupleDef(def, refs) {
18635
19177
  if (def.rest) {
18636
19178
  return {
@@ -18658,24 +19200,24 @@ function parseTupleDef(def, refs) {
18658
19200
  }
18659
19201
  }
18660
19202
 
18661
- // node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
19203
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
18662
19204
  function parseUndefinedDef(refs) {
18663
19205
  return {
18664
19206
  not: parseAnyDef(refs)
18665
19207
  };
18666
19208
  }
18667
19209
 
18668
- // node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
19210
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
18669
19211
  function parseUnknownDef(refs) {
18670
19212
  return parseAnyDef(refs);
18671
19213
  }
18672
19214
 
18673
- // node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
19215
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
18674
19216
  var parseReadonlyDef = (def, refs) => {
18675
19217
  return parseDef(def.innerType._def, refs);
18676
19218
  };
18677
19219
 
18678
- // node_modules/zod-to-json-schema/dist/esm/selectParser.js
19220
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js
18679
19221
  var selectParser = (def, typeName, refs) => {
18680
19222
  switch (typeName) {
18681
19223
  case ZodFirstPartyTypeKind.ZodString:
@@ -18753,7 +19295,7 @@ var selectParser = (def, typeName, refs) => {
18753
19295
  }
18754
19296
  };
18755
19297
 
18756
- // node_modules/zod-to-json-schema/dist/esm/parseDef.js
19298
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js
18757
19299
  function parseDef(def, refs, forceResolution = false) {
18758
19300
  const seenItem = refs.seen.get(def);
18759
19301
  if (refs.override) {
@@ -18808,7 +19350,7 @@ var addMeta = (def, refs, jsonSchema) => {
18808
19350
  }
18809
19351
  return jsonSchema;
18810
19352
  };
18811
- // node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
19353
+ // node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
18812
19354
  var zodToJsonSchema = (schema, options) => {
18813
19355
  const refs = getRefs(options);
18814
19356
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
@@ -18868,7 +19410,7 @@ var zodToJsonSchema = (schema, options) => {
18868
19410
  }
18869
19411
  return combined;
18870
19412
  };
18871
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
19413
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
18872
19414
  function mapMiniTarget(t) {
18873
19415
  if (!t)
18874
19416
  return "draft-7";
@@ -18910,7 +19452,7 @@ function parseWithCompat(schema, data) {
18910
19452
  return result.data;
18911
19453
  }
18912
19454
 
18913
- // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
19455
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
18914
19456
  var DEFAULT_REQUEST_TIMEOUT_MSEC = 60000;
18915
19457
 
18916
19458
  class Protocol {
@@ -19114,6 +19656,10 @@ class Protocol {
19114
19656
  this._progressHandlers.clear();
19115
19657
  this._taskProgressTokens.clear();
19116
19658
  this._pendingDebouncedNotifications.clear();
19659
+ for (const info of this._timeoutInfo.values()) {
19660
+ clearTimeout(info.timeoutId);
19661
+ }
19662
+ this._timeoutInfo.clear();
19117
19663
  for (const controller of this._requestHandlerAbortControllers.values()) {
19118
19664
  controller.abort();
19119
19665
  }
@@ -19244,7 +19790,9 @@ class Protocol {
19244
19790
  await capturedTransport?.send(errorResponse);
19245
19791
  }
19246
19792
  }).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
19247
- this._requestHandlerAbortControllers.delete(request.id);
19793
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
19794
+ this._requestHandlerAbortControllers.delete(request.id);
19795
+ }
19248
19796
  });
19249
19797
  }
19250
19798
  _onprogress(notification) {
@@ -19745,7 +20293,7 @@ function mergeCapabilities(base, additional) {
19745
20293
  return result;
19746
20294
  }
19747
20295
 
19748
- // node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
20296
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
19749
20297
  var import_ajv = __toESM(require_ajv(), 1);
19750
20298
  var import_ajv_formats = __toESM(require_dist(), 1);
19751
20299
  function createDefaultAjvInstance() {
@@ -19785,7 +20333,7 @@ class AjvJsonSchemaValidator {
19785
20333
  }
19786
20334
  }
19787
20335
 
19788
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
20336
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
19789
20337
  class ExperimentalServerTasks {
19790
20338
  constructor(_server) {
19791
20339
  this._server = _server;
@@ -19863,7 +20411,7 @@ class ExperimentalServerTasks {
19863
20411
  }
19864
20412
  }
19865
20413
 
19866
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
20414
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
19867
20415
  function assertToolsCallTaskCapability(requests, method, entityName) {
19868
20416
  if (!requests) {
19869
20417
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -19898,7 +20446,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
19898
20446
  }
19899
20447
  }
19900
20448
 
19901
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
20449
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
19902
20450
  class Server extends Protocol {
19903
20451
  constructor(_serverInfo, options) {
19904
20452
  super(options);
@@ -19946,16 +20494,7 @@ class Server extends Protocol {
19946
20494
  if (!methodSchema) {
19947
20495
  throw new Error("Schema is missing a method literal");
19948
20496
  }
19949
- let methodValue;
19950
- if (isZ4Schema(methodSchema)) {
19951
- const v4Schema = methodSchema;
19952
- const v4Def = v4Schema._zod?.def;
19953
- methodValue = v4Def?.value ?? v4Schema.value;
19954
- } else {
19955
- const v3Schema = methodSchema;
19956
- const legacyDef = v3Schema._def;
19957
- methodValue = legacyDef?.value ?? v3Schema.value;
19958
- }
20497
+ const methodValue = getLiteralValue(methodSchema);
19959
20498
  if (typeof methodValue !== "string") {
19960
20499
  throw new Error("Schema method literal must be a string");
19961
20500
  }
@@ -20231,7 +20770,7 @@ class Server extends Protocol {
20231
20770
  }
20232
20771
  }
20233
20772
 
20234
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
20773
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
20235
20774
  var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
20236
20775
  function isCompletable(schema) {
20237
20776
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
@@ -20245,7 +20784,7 @@ var McpZodTypeKind;
20245
20784
  McpZodTypeKind2["Completable"] = "McpCompletable";
20246
20785
  })(McpZodTypeKind || (McpZodTypeKind = {}));
20247
20786
 
20248
- // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
20787
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
20249
20788
  var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
20250
20789
  function validateToolName(name) {
20251
20790
  const warnings = [];
@@ -20303,7 +20842,7 @@ function validateAndWarnToolName(name) {
20303
20842
  return result.isValid;
20304
20843
  }
20305
20844
 
20306
- // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
20845
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
20307
20846
  class ExperimentalMcpServerTasks {
20308
20847
  constructor(_mcpServer) {
20309
20848
  this._mcpServer = _mcpServer;
@@ -20317,7 +20856,7 @@ class ExperimentalMcpServerTasks {
20317
20856
  return mcpServerInternal._createRegisteredTool(name, config2.title, config2.description, config2.inputSchema, config2.outputSchema, config2.annotations, execution, config2._meta, handler);
20318
20857
  }
20319
20858
  }
20320
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
20859
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
20321
20860
  class McpServer {
20322
20861
  constructor(serverInfo, options) {
20323
20862
  this._registeredResources = {};
@@ -20901,6 +21440,9 @@ class McpServer {
20901
21440
  annotations = rest.shift();
20902
21441
  }
20903
21442
  } else if (typeof firstArg === "object" && firstArg !== null) {
21443
+ if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) {
21444
+ throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
21445
+ }
20904
21446
  annotations = rest.shift();
20905
21447
  }
20906
21448
  }
@@ -20993,6 +21535,9 @@ function getZodSchemaObject(schema) {
20993
21535
  if (isZodRawShapeCompat(schema)) {
20994
21536
  return objectFromShape(schema);
20995
21537
  }
21538
+ if (!isZodSchemaInstance(schema)) {
21539
+ throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
21540
+ }
20996
21541
  return schema;
20997
21542
  }
20998
21543
  function promptArgumentsFromSchema(schema) {
@@ -21037,12 +21582,22 @@ var EMPTY_COMPLETION_RESULT = {
21037
21582
  }
21038
21583
  };
21039
21584
 
21040
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
21585
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
21041
21586
  import process2 from "process";
21042
21587
 
21043
- // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
21588
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
21589
+ var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
21590
+
21044
21591
  class ReadBuffer {
21592
+ constructor(options) {
21593
+ this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
21594
+ }
21045
21595
  append(chunk) {
21596
+ const newSize = (this._buffer?.length ?? 0) + chunk.length;
21597
+ if (newSize > this._maxBufferSize) {
21598
+ this.clear();
21599
+ throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
21600
+ }
21046
21601
  this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
21047
21602
  }
21048
21603
  readMessage() {
@@ -21070,20 +21625,25 @@ function serializeMessage(message) {
21070
21625
  `;
21071
21626
  }
21072
21627
 
21073
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
21628
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
21074
21629
  class StdioServerTransport {
21075
- constructor(_stdin = process2.stdin, _stdout = process2.stdout) {
21630
+ constructor(_stdin = process2.stdin, _stdout = process2.stdout, options) {
21076
21631
  this._stdin = _stdin;
21077
21632
  this._stdout = _stdout;
21078
- this._readBuffer = new ReadBuffer;
21079
21633
  this._started = false;
21080
21634
  this._ondata = (chunk) => {
21081
- this._readBuffer.append(chunk);
21082
- this.processReadBuffer();
21635
+ try {
21636
+ this._readBuffer.append(chunk);
21637
+ this.processReadBuffer();
21638
+ } catch (error2) {
21639
+ this.onerror?.(error2);
21640
+ this.close().catch(() => {});
21641
+ }
21083
21642
  };
21084
21643
  this._onerror = (error2) => {
21085
21644
  this.onerror?.(error2);
21086
21645
  };
21646
+ this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
21087
21647
  }
21088
21648
  async start() {
21089
21649
  if (this._started) {
@@ -21293,6 +21853,7 @@ function getStorageStatus(db = getDatabase()) {
21293
21853
 
21294
21854
  // src/store/index.ts
21295
21855
  init_contacts();
21856
+ init_project_memberships2();
21296
21857
 
21297
21858
  // src/db/companies.ts
21298
21859
  init_types();
@@ -22821,13 +23382,24 @@ init_database();
22821
23382
  // src/lib/vault.ts
22822
23383
  init_database();
22823
23384
  import { existsSync as existsSync4, readFileSync as readFileSync2, writeFileSync, mkdirSync as mkdirSync3, unlinkSync } from "fs";
22824
- import { join as join3 } from "path";
22825
- import { createCipheriv, createDecipheriv, randomBytes, pbkdf2Sync, createHash } from "crypto";
22826
- var VAULT_DIR = getDataDir();
22827
- var VAULT_CONFIG = join3(VAULT_DIR, "vault.json");
22828
- var VAULT_SESSION = join3(VAULT_DIR, ".vault-session");
22829
- var DOCUMENTS_DIR = join3(VAULT_DIR, "documents");
23385
+ import { join as join4 } from "path";
23386
+ import { createCipheriv, createDecipheriv, randomBytes, pbkdf2Sync, createHash as createHash2 } from "crypto";
22830
23387
  var SESSION_TTL_MS = 30 * 60 * 1000;
23388
+ function getVaultDir() {
23389
+ return getDataDir();
23390
+ }
23391
+ function getVaultConfigPath() {
23392
+ return join4(getDataDir(), "vault.json");
23393
+ }
23394
+ function getVaultSessionPath() {
23395
+ return join4(getStateDir(), ".vault-session");
23396
+ }
23397
+ function getDocumentsDir() {
23398
+ const dir = join4(getDataDir(), "documents");
23399
+ if (!existsSync4(dir))
23400
+ mkdirSync3(dir, { recursive: true });
23401
+ return dir;
23402
+ }
22831
23403
  var _derivedKey = null;
22832
23404
  function deriveKey(passphrase, salt) {
22833
23405
  return pbkdf2Sync(passphrase, salt, 1e5, 32, "sha512");
@@ -22837,16 +23409,17 @@ function saveSession(key) {
22837
23409
  key: key.toString("hex"),
22838
23410
  expires_at: new Date(Date.now() + SESSION_TTL_MS).toISOString()
22839
23411
  };
22840
- writeFileSync(VAULT_SESSION, JSON.stringify(session), { mode: 384 });
23412
+ writeFileSync(getVaultSessionPath(), JSON.stringify(session), { mode: 384 });
22841
23413
  }
22842
23414
  function loadSession() {
22843
- if (!existsSync4(VAULT_SESSION))
23415
+ const sessionPath = getVaultSessionPath();
23416
+ if (!existsSync4(sessionPath))
22844
23417
  return null;
22845
23418
  try {
22846
- const session = JSON.parse(readFileSync2(VAULT_SESSION, "utf-8"));
23419
+ const session = JSON.parse(readFileSync2(sessionPath, "utf-8"));
22847
23420
  if (new Date(session.expires_at).getTime() < Date.now()) {
22848
23421
  try {
22849
- unlinkSync(VAULT_SESSION);
23422
+ unlinkSync(sessionPath);
22850
23423
  } catch {}
22851
23424
  return null;
22852
23425
  }
@@ -22857,33 +23430,33 @@ function loadSession() {
22857
23430
  }
22858
23431
  function clearSession() {
22859
23432
  try {
22860
- if (existsSync4(VAULT_SESSION))
22861
- unlinkSync(VAULT_SESSION);
23433
+ if (existsSync4(getVaultSessionPath()))
23434
+ unlinkSync(getVaultSessionPath());
22862
23435
  } catch {}
22863
23436
  }
22864
23437
  function initVault(passphrase) {
22865
- if (!existsSync4(VAULT_DIR))
22866
- mkdirSync3(VAULT_DIR, { recursive: true });
22867
- if (!existsSync4(DOCUMENTS_DIR))
22868
- mkdirSync3(DOCUMENTS_DIR, { recursive: true });
23438
+ const vaultDir = getVaultDir();
23439
+ if (!existsSync4(vaultDir))
23440
+ mkdirSync3(vaultDir, { recursive: true });
23441
+ mkdirSync3(getDocumentsDir(), { recursive: true });
22869
23442
  const salt = randomBytes(32);
22870
23443
  const key = deriveKey(passphrase, salt);
22871
- const keyHash = createHash("sha256").update(key).digest("hex");
23444
+ const keyHash = createHash2("sha256").update(key).digest("hex");
22872
23445
  const config2 = { salt: salt.toString("hex"), key_hash: keyHash, created_at: new Date().toISOString() };
22873
- writeFileSync(VAULT_CONFIG, JSON.stringify(config2, null, 2));
23446
+ writeFileSync(getVaultConfigPath(), JSON.stringify(config2, null, 2));
22874
23447
  _derivedKey = key;
22875
23448
  saveSession(key);
22876
23449
  }
22877
23450
  function isVaultInitialized() {
22878
- return existsSync4(VAULT_CONFIG);
23451
+ return existsSync4(getVaultConfigPath());
22879
23452
  }
22880
23453
  function unlockVault(passphrase) {
22881
- if (!existsSync4(VAULT_CONFIG))
23454
+ if (!existsSync4(getVaultConfigPath()))
22882
23455
  throw new Error("Vault not initialized. Run 'contacts vault init' first.");
22883
- const config2 = JSON.parse(readFileSync2(VAULT_CONFIG, "utf-8"));
23456
+ const config2 = JSON.parse(readFileSync2(getVaultConfigPath(), "utf-8"));
22884
23457
  const salt = Buffer.from(config2.salt, "hex");
22885
23458
  const key = deriveKey(passphrase, salt);
22886
- const keyHash = createHash("sha256").update(key).digest("hex");
23459
+ const keyHash = createHash2("sha256").update(key).digest("hex");
22887
23460
  if (keyHash !== config2.key_hash)
22888
23461
  return false;
22889
23462
  _derivedKey = key;
@@ -22935,10 +23508,11 @@ function decrypt(ciphertext, iv) {
22935
23508
  return decrypted;
22936
23509
  }
22937
23510
  function storeFile(sourcePath, entityId) {
22938
- if (!existsSync4(DOCUMENTS_DIR))
22939
- mkdirSync3(DOCUMENTS_DIR, { recursive: true });
23511
+ const documentsDir = getDocumentsDir();
23512
+ if (!existsSync4(documentsDir))
23513
+ mkdirSync3(documentsDir, { recursive: true });
22940
23514
  const ext = sourcePath.split(".").pop() || "bin";
22941
- const destPath = join3(DOCUMENTS_DIR, `${entityId}.${ext}`);
23515
+ const destPath = join4(documentsDir, `${entityId}.${ext}`);
22942
23516
  const data = readFileSync2(sourcePath);
22943
23517
  writeFileSync(destPath, data);
22944
23518
  return destPath;
@@ -23853,12 +24427,16 @@ async function assembleContext(contactIds, format = "meeting_prep", db) {
23853
24427
  // src/lib/images.ts
23854
24428
  init_database();
23855
24429
  import { existsSync as existsSync6, mkdirSync as mkdirSync4, copyFileSync as copyFileSync2, unlinkSync as unlinkSync3, readdirSync as readdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
23856
- import { join as join4, extname, basename } from "path";
23857
- var IMAGES_DIR = join4(getDataDir(), "images");
24430
+ import { join as join5, extname, basename } from "path";
24431
+ var IMAGES_DIR = join5(getDataDir(), "images");
23858
24432
  function ensureImagesDir() {
23859
24433
  if (!existsSync6(IMAGES_DIR))
23860
24434
  mkdirSync4(IMAGES_DIR, { recursive: true });
23861
24435
  }
24436
+ function getImagesDir() {
24437
+ ensureImagesDir();
24438
+ return IMAGES_DIR;
24439
+ }
23862
24440
  function saveImage(entityId, source, options) {
23863
24441
  ensureImagesDir();
23864
24442
  deleteImage(entityId);
@@ -23867,14 +24445,14 @@ function saveImage(entityId, source, options) {
23867
24445
  const ext2 = base64Match[1] === "jpeg" ? "jpg" : base64Match[1];
23868
24446
  const data = Buffer.from(base64Match[2], "base64");
23869
24447
  const filename2 = `${entityId}.${ext2}`;
23870
- writeFileSync2(join4(IMAGES_DIR, filename2), data);
24448
+ writeFileSync2(join5(IMAGES_DIR, filename2), data);
23871
24449
  return filename2;
23872
24450
  }
23873
24451
  if (!existsSync6(source) && /^[A-Za-z0-9+/=\n\r]+$/.test(source.trim()) && source.length > 100) {
23874
24452
  const ext2 = options?.format || "jpg";
23875
24453
  const data = Buffer.from(source.trim(), "base64");
23876
24454
  const filename2 = `${entityId}.${ext2}`;
23877
- writeFileSync2(join4(IMAGES_DIR, filename2), data);
24455
+ writeFileSync2(join5(IMAGES_DIR, filename2), data);
23878
24456
  return filename2;
23879
24457
  }
23880
24458
  if (!existsSync6(source)) {
@@ -23886,14 +24464,14 @@ function saveImage(entityId, source, options) {
23886
24464
  throw new Error(`Unsupported image format: ${ext}. Supported: ${validExts.join(", ")}`);
23887
24465
  }
23888
24466
  const filename = `${entityId}.${ext === "jpeg" ? "jpg" : ext}`;
23889
- copyFileSync2(source, join4(IMAGES_DIR, filename));
24467
+ copyFileSync2(source, join5(IMAGES_DIR, filename));
23890
24468
  return filename;
23891
24469
  }
23892
24470
  function getImagePath(entityId) {
23893
24471
  ensureImagesDir();
23894
24472
  const files = readdirSync2(IMAGES_DIR);
23895
24473
  const match = files.find((f) => f.startsWith(`${entityId}.`));
23896
- return match ? join4(IMAGES_DIR, match) : null;
24474
+ return match ? join5(IMAGES_DIR, match) : null;
23897
24475
  }
23898
24476
  function getImageAsBase64(entityId) {
23899
24477
  const path = getImagePath(entityId);
@@ -23910,7 +24488,7 @@ function deleteImage(entityId) {
23910
24488
  let deleted = false;
23911
24489
  for (const f of files) {
23912
24490
  if (f.startsWith(`${entityId}.`)) {
23913
- unlinkSync3(join4(IMAGES_DIR, f));
24491
+ unlinkSync3(join5(IMAGES_DIR, f));
23914
24492
  deleted = true;
23915
24493
  }
23916
24494
  }
@@ -23922,7 +24500,7 @@ function listImages() {
23922
24500
  return files.map((f) => ({
23923
24501
  entity_id: basename(f, extname(f)),
23924
24502
  filename: f,
23925
- path: join4(IMAGES_DIR, f)
24503
+ path: join5(IMAGES_DIR, f)
23926
24504
  }));
23927
24505
  }
23928
24506
 
@@ -24419,6 +24997,15 @@ class LocalStore {
24419
24997
  async listContactIdsByProject(projectId) {
24420
24998
  return listContactIdsByProject(projectId, this.db);
24421
24999
  }
25000
+ async readContactProjectMembership(contactId, projectId) {
25001
+ return readContactProjectMembership(contactId, projectId, this.db);
25002
+ }
25003
+ async listContactProjectMemberships(projectId, maxItems) {
25004
+ return listContactProjectMemberships(projectId, maxItems, this.db);
25005
+ }
25006
+ async mutateContactProjectMembership(direction, input) {
25007
+ return mutateContactProjectMembership(direction, input, this.db);
25008
+ }
24422
25009
  async createCompany(input) {
24423
25010
  return createCompany(input, this.db);
24424
25011
  }
@@ -25041,20 +25628,33 @@ class ApiStore {
25041
25628
  async findContactByEmailAddress(address) {
25042
25629
  return this.getContactByEmail(address);
25043
25630
  }
25044
- async linkContactToProject() {
25045
- return unavailable("linkContactToProject");
25631
+ async linkContactToProject(contactId, projectId) {
25632
+ await this.client.transport.put(`/contacts/${this.enc(contactId)}/projects/${this.enc(projectId)}`);
25633
+ }
25634
+ async unlinkContactFromProject(contactId, projectId) {
25635
+ await this.del(`/contacts/${this.enc(contactId)}/projects/${this.enc(projectId)}`);
25636
+ }
25637
+ async getContactProjectIds(contactId) {
25638
+ return pick2(await this.g(`/contacts/${this.enc(contactId)}/projects`), "project_ids") ?? [];
25046
25639
  }
25047
- async unlinkContactFromProject() {
25048
- return unavailable("unlinkContactFromProject");
25640
+ async setContactProjects(contactId, projectIds) {
25641
+ await this.client.transport.put(`/contacts/${this.enc(contactId)}/projects`, { project_ids: projectIds });
25049
25642
  }
25050
- async getContactProjectIds() {
25051
- return unavailable("getContactProjectIds");
25643
+ async listContactIdsByProject(projectId) {
25644
+ return pick2(await this.g(`/projects/${this.enc(projectId)}/contacts`), "contact_ids") ?? [];
25052
25645
  }
25053
- async setContactProjects() {
25054
- return unavailable("setContactProjects");
25646
+ async readContactProjectMembership(contactId, projectId) {
25647
+ return this.client.transport.get(`/projects/${this.enc(projectId)}/contact-memberships/${this.enc(contactId)}`);
25055
25648
  }
25056
- async listContactIdsByProject() {
25057
- return unavailable("listContactIdsByProject");
25649
+ async listContactProjectMemberships(projectId, maxItems) {
25650
+ return this.client.transport.get(`/projects/${this.enc(projectId)}/contact-memberships`, { query: { max_items: maxItems } });
25651
+ }
25652
+ async mutateContactProjectMembership(direction, input) {
25653
+ return this.client.transport.post(`/projects/${this.enc(input.project_id)}/contact-memberships/${this.enc(input.contact_id)}/${direction}`, {
25654
+ operation_id: input.operation_id,
25655
+ step_id: input.step_id,
25656
+ expected_version: input.expected_version
25657
+ });
25058
25658
  }
25059
25659
  async createCompany(input) {
25060
25660
  const res = await this.client.create("companies", stripUndefined(input));
@@ -27441,6 +28041,7 @@ Only include fields that are actually visible in the document. Return valid JSON
27441
28041
  }
27442
28042
 
27443
28043
  // src/mcp/handlers/advanced.ts
28044
+ import { join as join6 } from "path";
27444
28045
  var json3 = (v) => ({
27445
28046
  content: [{ type: "text", text: JSON.stringify(v, null, 2) }]
27446
28047
  });
@@ -27448,8 +28049,8 @@ var _contactsAgents = new Map;
27448
28049
  var advancedHandlers = {
27449
28050
  get_field_history: async (a) => json3({ history: await getStore().getFieldHistory(a.contact_id, a.field_name) }),
27450
28051
  get_contact_at: async (a) => {
27451
- const snapshot = await getStore().getContactAt(a.contact_id, a.timestamp);
27452
- return json3({ contact_id: a.contact_id, timestamp: a.timestamp, snapshot });
28052
+ const snapshot2 = await getStore().getContactAt(a.contact_id, a.timestamp);
28053
+ return json3({ contact_id: a.contact_id, timestamp: a.timestamp, snapshot: snapshot2 });
27453
28054
  },
27454
28055
  get_job_history: async (a) => json3({ history: await getStore().getJobHistory(a.contact_id) }),
27455
28056
  add_job_entry: async (a) => json3(await getStore().addJobEntry(a.contact_id, {
@@ -27602,8 +28203,9 @@ var advancedHandlers = {
27602
28203
  const { contact_id, image, format } = a;
27603
28204
  await store.getContact(contact_id);
27604
28205
  const filename = await store.saveImage(contact_id, image, { format });
27605
- await store.updateContact(contact_id, { avatar_url: `~/.hasna/contacts/images/${filename}` });
27606
- return json3({ ok: true, contact_id, filename, avatar_url: `~/.hasna/contacts/images/${filename}` });
28206
+ const avatarUrl = join6(getImagesDir(), filename);
28207
+ await store.updateContact(contact_id, { avatar_url: avatarUrl });
28208
+ return json3({ ok: true, contact_id, filename, avatar_url: avatarUrl });
27607
28209
  },
27608
28210
  get_contact_photo: async (a) => {
27609
28211
  const { contact_id } = a;
@@ -27625,8 +28227,9 @@ var advancedHandlers = {
27625
28227
  const { company_id, image, format } = a;
27626
28228
  await store.getCompany(company_id);
27627
28229
  const filename = await store.saveImage(company_id, image, { format });
27628
- await store.updateCompany(company_id, { logo_url: `~/.hasna/contacts/images/${filename}` });
27629
- return json3({ ok: true, company_id, filename, logo_url: `~/.hasna/contacts/images/${filename}` });
28230
+ const logoUrl = join6(getImagesDir(), filename);
28231
+ await store.updateCompany(company_id, { logo_url: logoUrl });
28232
+ return json3({ ok: true, company_id, filename, logo_url: logoUrl });
27630
28233
  },
27631
28234
  get_company_logo: async (a) => {
27632
28235
  const { company_id } = a;
@@ -27925,11 +28528,11 @@ function jsonSchemaToZodType(schema) {
27925
28528
  }
27926
28529
  function jsonSchemaToZodObject(schema) {
27927
28530
  const objectSchema = schema && typeof schema === "object" ? schema : {};
27928
- const required2 = new Set(objectSchema.required ?? []);
28531
+ const required3 = new Set(objectSchema.required ?? []);
27929
28532
  const shape = {};
27930
28533
  for (const [key, value] of Object.entries(objectSchema.properties ?? {})) {
27931
28534
  const propertySchema = jsonSchemaToZodType(value);
27932
- shape[key] = required2.has(key) ? propertySchema : propertySchema.optional();
28535
+ shape[key] = required3.has(key) ? propertySchema : propertySchema.optional();
27933
28536
  }
27934
28537
  return describeSchema(exports_external.object(shape).passthrough(), objectSchema.description);
27935
28538
  }
@@ -29397,10 +30000,10 @@ var TOOL_DEFINITIONS = [
29397
30000
  { name: "get_deal_team", description: "Get the full buying committee for a deal with contact names and roles.", inputSchema: { type: "object", properties: { deal_id: { type: "string" } }, required: ["deal_id"] } },
29398
30001
  { name: "get_coverage_gaps", description: "Identify coverage gaps in a company account \u2014 missing economic buyer, technical evaluator, or org chart relationships.", inputSchema: { type: "object", properties: { company_id: { type: "string" } }, required: ["company_id"] } },
29399
30002
  { name: "get_recent_contact_events", description: "Polling fallback for change events \u2014 returns recent activity log entries, optionally filtered by event type or date.", inputSchema: { type: "object", properties: { since: { type: "string", description: "ISO 8601 datetime \u2014 only events after this date" }, event_types: { type: "array", items: { type: "string" } } } } },
29400
- { name: "set_contact_photo", description: "Set a contact's profile photo. Provide either a local file path or base64-encoded image data (with or without data URI prefix). Stores image in ~/.hasna/contacts/images/ and updates avatar_url. Supported formats: jpg, png, gif, webp, svg, avif.", inputSchema: { type: "object", properties: { contact_id: { type: "string" }, image: { type: "string", description: "File path (e.g. /tmp/photo.jpg) OR base64 data (e.g. data:image/png;base64,...) OR raw base64 string" }, format: { type: "string", description: "Image format hint when using raw base64 (jpg, png, webp). Not needed for file paths or data URIs." } }, required: ["contact_id", "image"] } },
30003
+ { name: "set_contact_photo", description: "Set a contact's profile photo. Provide either a local file path or base64-encoded image data (with or without data URI prefix). Stores image in the XDG data root images dir and updates avatar_url. Supported formats: jpg, png, gif, webp, svg, avif.", inputSchema: { type: "object", properties: { contact_id: { type: "string" }, image: { type: "string", description: "File path (e.g. /tmp/photo.jpg) OR base64 data (e.g. data:image/png;base64,...) OR raw base64 string" }, format: { type: "string", description: "Image format hint when using raw base64 (jpg, png, webp). Not needed for file paths or data URIs." } }, required: ["contact_id", "image"] } },
29401
30004
  { name: "get_contact_photo", description: "Get a contact's profile photo as base64 data URI. Returns null if no photo is set.", inputSchema: { type: "object", properties: { contact_id: { type: "string" } }, required: ["contact_id"] } },
29402
30005
  { name: "delete_contact_photo", description: "Remove a contact's profile photo.", inputSchema: { type: "object", properties: { contact_id: { type: "string" } }, required: ["contact_id"] } },
29403
- { name: "set_company_logo", description: "Set a company's logo image. Provide either a local file path or base64-encoded image data. Stores image in ~/.hasna/contacts/images/ and updates logo_url.", inputSchema: { type: "object", properties: { company_id: { type: "string" }, image: { type: "string", description: "File path or base64 data" }, format: { type: "string", description: "Image format hint for raw base64" } }, required: ["company_id", "image"] } },
30006
+ { name: "set_company_logo", description: "Set a company's logo image. Provide either a local file path or base64-encoded image data. Stores image in the XDG data root images dir and updates logo_url.", inputSchema: { type: "object", properties: { company_id: { type: "string" }, image: { type: "string", description: "File path or base64 data" }, format: { type: "string", description: "Image format hint for raw base64" } }, required: ["company_id", "image"] } },
29404
30007
  { name: "get_company_logo", description: "Get a company's logo as base64 data URI.", inputSchema: { type: "object", properties: { company_id: { type: "string" } }, required: ["company_id"] } },
29405
30008
  { name: "delete_company_logo", description: "Remove a company's logo image.", inputSchema: { type: "object", properties: { company_id: { type: "string" } }, required: ["company_id"] } },
29406
30009
  { name: "set_sensitivity", description: "Set a contact's sensitivity level (normal, confidential, restricted). Restricted contacts are hidden from list/search unless explicitly requested.", inputSchema: { type: "object", properties: { contact_id: { type: "string" }, sensitivity: { type: "string", enum: ["normal", "confidential", "restricted"] } }, required: ["contact_id", "sensitivity"] } },
@@ -29408,7 +30011,7 @@ var TOOL_DEFINITIONS = [
29408
30011
  { name: "vault_unlock", description: "Unlock the vault for this session with a passphrase.", inputSchema: { type: "object", properties: { passphrase: { type: "string" } }, required: ["passphrase"] } },
29409
30012
  { name: "vault_lock", description: "Lock the vault, clearing the encryption key from memory.", inputSchema: { type: "object", properties: {} } },
29410
30013
  { name: "vault_status", description: "Check vault initialization and lock status.", inputSchema: { type: "object", properties: {} } },
29411
- { name: "add_document", description: "Store a document for a contact (passport, tax_id, medical_record, etc.). Text values are encrypted; file attachments are stored plain so agents can read them. Vault must be unlocked.", inputSchema: { type: "object", properties: { contact_id: { type: "string" }, doc_type: { type: "string", enum: [...DOCUMENT_TYPES] }, label: { type: "string" }, value: { type: "string", description: "Plaintext value (will be encrypted in DB)" }, file_path: { type: "string", description: "File to attach \u2014 stored PLAIN in ~/.hasna/contacts/documents/ for agent access" }, metadata: { type: "object" }, expires_at: { type: "string" } }, required: ["contact_id", "doc_type", "value"] } },
30014
+ { name: "add_document", description: "Store a document for a contact (passport, tax_id, medical_record, etc.). Text values are encrypted; file attachments are stored plain so agents can read them. Vault must be unlocked.", inputSchema: { type: "object", properties: { contact_id: { type: "string" }, doc_type: { type: "string", enum: [...DOCUMENT_TYPES] }, label: { type: "string" }, value: { type: "string", description: "Plaintext value (will be encrypted in DB)" }, file_path: { type: "string", description: "File to attach \u2014 stored PLAIN in the XDG data root documents dir for agent access" }, metadata: { type: "object" }, expires_at: { type: "string" } }, required: ["contact_id", "doc_type", "value"] } },
29412
30015
  { name: "list_documents", description: "List documents for a contact (metadata only \u2014 no decryption needed). Returns file_path for attachments so agents can read them directly.", inputSchema: { type: "object", properties: { contact_id: { type: "string" } }, required: ["contact_id"] } },
29413
30016
  { name: "get_document", description: "Get a document with decrypted value and file_path. Vault must be unlocked for the text value; file is always accessible.", inputSchema: { type: "object", properties: { document_id: { type: "string" } }, required: ["document_id"] } },
29414
30017
  { name: "get_document_file", description: "Get the plain file path for a document attachment. Agents can read this file directly \u2014 it is NOT encrypted. Returns null if no file attached.", inputSchema: { type: "object", properties: { document_id: { type: "string" } }, required: ["document_id"] } },
@@ -29515,17 +30118,54 @@ function registerContactsStorageTools(server) {
29515
30118
  });
29516
30119
  }
29517
30120
 
29518
- // node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
30121
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
30122
+ var import_content_type = __toESM(require_content_type(), 1);
30123
+ function mediaTypeEssence(header) {
30124
+ if (!header) {
30125
+ return;
30126
+ }
30127
+ try {
30128
+ return import_content_type.default.parse(header).type;
30129
+ } catch {
30130
+ const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
30131
+ if (essence === "" || header.slice(essence.length).includes(",")) {
30132
+ return;
30133
+ }
30134
+ return essence;
30135
+ }
30136
+ }
30137
+ function isJsonContentType(header) {
30138
+ if (header === "application/json") {
30139
+ return true;
30140
+ }
30141
+ return mediaTypeEssence(header) === "application/json";
30142
+ }
30143
+
30144
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js
30145
+ var DEFAULT_SSE_KEEP_ALIVE_MS = 15000;
30146
+ var MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
30147
+ function armSseKeepAlive(intervalMs, onTick) {
30148
+ if (!Number.isFinite(intervalMs) || intervalMs < 1) {
30149
+ return;
30150
+ }
30151
+ const timer = setInterval(onTick, Math.min(intervalMs, MAX_TIMER_DELAY_MS));
30152
+ timer.unref?.();
30153
+ return timer;
30154
+ }
30155
+
30156
+ // node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
29519
30157
  class WebStandardStreamableHTTPServerTransport {
29520
30158
  constructor(options = {}) {
29521
30159
  this._started = false;
29522
30160
  this._hasHandledRequest = false;
29523
30161
  this._streamMapping = new Map;
29524
30162
  this._requestToStreamMapping = new Map;
30163
+ this._resumableStreams = new Set;
29525
30164
  this._requestResponseMap = new Map;
29526
30165
  this._initialized = false;
29527
30166
  this._enableJsonResponse = false;
29528
30167
  this._standaloneSseStreamId = "_GET_stream";
30168
+ this._closed = false;
29529
30169
  this.sessionIdGenerator = options.sessionIdGenerator;
29530
30170
  this._enableJsonResponse = options.enableJsonResponse ?? false;
29531
30171
  this._eventStore = options.eventStore;
@@ -29535,6 +30175,22 @@ class WebStandardStreamableHTTPServerTransport {
29535
30175
  this._allowedOrigins = options.allowedOrigins;
29536
30176
  this._enableDnsRebindingProtection = options.enableDnsRebindingProtection ?? false;
29537
30177
  this._retryInterval = options.retryInterval;
30178
+ this._keepAliveMs = options.keepAliveMs ?? DEFAULT_SSE_KEEP_ALIVE_MS;
30179
+ }
30180
+ startKeepAlive(controller, encoder) {
30181
+ if (this._closed)
30182
+ return;
30183
+ const timer = armSseKeepAlive(this._keepAliveMs, () => {
30184
+ try {
30185
+ controller.enqueue(encoder.encode(`: keepalive
30186
+
30187
+ `));
30188
+ } catch {
30189
+ if (timer !== undefined)
30190
+ clearInterval(timer);
30191
+ }
30192
+ });
30193
+ return timer;
29538
30194
  }
29539
30195
  async start() {
29540
30196
  if (this._started) {
@@ -29582,6 +30238,9 @@ class WebStandardStreamableHTTPServerTransport {
29582
30238
  return;
29583
30239
  }
29584
30240
  async handleRequest(req, options) {
30241
+ if (this._closed) {
30242
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
30243
+ }
29585
30244
  if (!this.sessionIdGenerator && this._hasHandledRequest) {
29586
30245
  throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");
29587
30246
  }
@@ -29621,6 +30280,7 @@ data:
29621
30280
  `;
29622
30281
  }
29623
30282
  controller.enqueue(encoder.encode(primingEvent));
30283
+ this._resumableStreams.add(streamId);
29624
30284
  }
29625
30285
  async handleGetRequest(req) {
29626
30286
  const acceptHeader = req.headers.get("accept");
@@ -29648,18 +30308,25 @@ data:
29648
30308
  }
29649
30309
  const encoder = new TextEncoder;
29650
30310
  let streamController;
30311
+ let keepAliveTimer = undefined;
29651
30312
  const readable = new ReadableStream({
29652
30313
  start: (controller) => {
29653
30314
  streamController = controller;
29654
30315
  },
29655
30316
  cancel: () => {
29656
- this._streamMapping.delete(this._standaloneSseStreamId);
30317
+ if (keepAliveTimer !== undefined) {
30318
+ clearInterval(keepAliveTimer);
30319
+ }
30320
+ if (this._streamMapping.get(this._standaloneSseStreamId)?.controller === streamController) {
30321
+ this._streamMapping.delete(this._standaloneSseStreamId);
30322
+ }
29657
30323
  }
29658
30324
  });
29659
30325
  const headers = {
29660
30326
  "Content-Type": "text/event-stream",
29661
30327
  "Cache-Control": "no-cache, no-transform",
29662
- Connection: "keep-alive"
30328
+ Connection: "keep-alive",
30329
+ "X-Accel-Buffering": "no"
29663
30330
  };
29664
30331
  if (this.sessionId !== undefined) {
29665
30332
  headers["mcp-session-id"] = this.sessionId;
@@ -29668,12 +30335,16 @@ data:
29668
30335
  controller: streamController,
29669
30336
  encoder,
29670
30337
  cleanup: () => {
30338
+ if (keepAliveTimer !== undefined) {
30339
+ clearInterval(keepAliveTimer);
30340
+ }
29671
30341
  this._streamMapping.delete(this._standaloneSseStreamId);
29672
30342
  try {
29673
30343
  streamController.close();
29674
30344
  } catch {}
29675
30345
  }
29676
30346
  });
30347
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
29677
30348
  return new Response(readable, { headers });
29678
30349
  }
29679
30350
  async replayEvents(lastEventId) {
@@ -29697,20 +30368,33 @@ data:
29697
30368
  const headers = {
29698
30369
  "Content-Type": "text/event-stream",
29699
30370
  "Cache-Control": "no-cache, no-transform",
29700
- Connection: "keep-alive"
30371
+ Connection: "keep-alive",
30372
+ "X-Accel-Buffering": "no"
29701
30373
  };
29702
30374
  if (this.sessionId !== undefined) {
29703
30375
  headers["mcp-session-id"] = this.sessionId;
29704
30376
  }
29705
30377
  const encoder = new TextEncoder;
29706
30378
  let streamController;
30379
+ let keepAliveTimer = undefined;
30380
+ let replayedStreamId = undefined;
30381
+ let cancelled = false;
29707
30382
  const readable = new ReadableStream({
29708
30383
  start: (controller) => {
29709
30384
  streamController = controller;
29710
30385
  },
29711
- cancel: () => {}
30386
+ cancel: () => {
30387
+ cancelled = true;
30388
+ if (keepAliveTimer !== undefined) {
30389
+ clearInterval(keepAliveTimer);
30390
+ }
30391
+ if (replayedStreamId !== undefined && this._streamMapping.get(replayedStreamId)?.controller === streamController) {
30392
+ this._streamMapping.delete(replayedStreamId);
30393
+ }
30394
+ }
29712
30395
  });
29713
- const replayedStreamId = await this._eventStore.replayEventsAfter(lastEventId, {
30396
+ const replayedEventIds = new Set;
30397
+ replayedStreamId = await this._eventStore.replayEventsAfter(lastEventId, {
29714
30398
  send: async (eventId, message) => {
29715
30399
  const success = this.writeSSEEvent(streamController, encoder, message, eventId);
29716
30400
  if (!success) {
@@ -29718,19 +30402,34 @@ data:
29718
30402
  try {
29719
30403
  streamController.close();
29720
30404
  } catch {}
30405
+ } else {
30406
+ replayedEventIds.add(eventId);
29721
30407
  }
29722
30408
  }
29723
30409
  });
30410
+ if (this._closed || cancelled) {
30411
+ try {
30412
+ streamController.close();
30413
+ } catch {}
30414
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
30415
+ }
30416
+ this._streamMapping.get(replayedStreamId)?.cleanup();
29724
30417
  this._streamMapping.set(replayedStreamId, {
29725
30418
  controller: streamController,
29726
30419
  encoder,
30420
+ replayedEventIds,
29727
30421
  cleanup: () => {
30422
+ if (keepAliveTimer !== undefined) {
30423
+ clearInterval(keepAliveTimer);
30424
+ }
29728
30425
  this._streamMapping.delete(replayedStreamId);
29729
30426
  try {
29730
30427
  streamController.close();
29731
30428
  } catch {}
29732
30429
  }
29733
30430
  });
30431
+ this._resumableStreams.add(replayedStreamId);
30432
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
29734
30433
  return new Response(readable, { headers });
29735
30434
  } catch (error2) {
29736
30435
  this.onerror?.(error2);
@@ -29780,7 +30479,7 @@ data:
29780
30479
  return this.createJsonErrorResponse(406, -32000, "Not Acceptable: Client must accept both application/json and text/event-stream");
29781
30480
  }
29782
30481
  const ct = req.headers.get("content-type");
29783
- if (!ct || !ct.includes("application/json")) {
30482
+ if (!isJsonContentType(ct)) {
29784
30483
  this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json"));
29785
30484
  return this.createJsonErrorResponse(415, -32000, "Unsupported Media Type: Content-Type must be application/json");
29786
30485
  }
@@ -29810,6 +30509,9 @@ data:
29810
30509
  this.onerror?.(new Error("Parse error: Invalid JSON-RPC message"));
29811
30510
  return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
29812
30511
  }
30512
+ if (this._closed) {
30513
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
30514
+ }
29813
30515
  const isInitializationRequest = messages.some(isInitializeRequest);
29814
30516
  if (isInitializationRequest) {
29815
30517
  if (this._initialized && this.sessionId !== undefined) {
@@ -29836,6 +30538,9 @@ data:
29836
30538
  return protocolError;
29837
30539
  }
29838
30540
  }
30541
+ if (this._closed) {
30542
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
30543
+ }
29839
30544
  const hasRequests = messages.some(isJSONRPCRequest);
29840
30545
  if (!hasRequests) {
29841
30546
  for (const message of messages) {
@@ -29866,18 +30571,25 @@ data:
29866
30571
  }
29867
30572
  const encoder = new TextEncoder;
29868
30573
  let streamController;
30574
+ let keepAliveTimer = undefined;
29869
30575
  const readable = new ReadableStream({
29870
30576
  start: (controller) => {
29871
30577
  streamController = controller;
29872
30578
  },
29873
30579
  cancel: () => {
29874
- this._streamMapping.delete(streamId);
30580
+ if (keepAliveTimer !== undefined) {
30581
+ clearInterval(keepAliveTimer);
30582
+ }
30583
+ if (this._streamMapping.get(streamId)?.controller === streamController) {
30584
+ this._streamMapping.delete(streamId);
30585
+ }
29875
30586
  }
29876
30587
  });
29877
30588
  const headers = {
29878
30589
  "Content-Type": "text/event-stream",
29879
- "Cache-Control": "no-cache",
29880
- Connection: "keep-alive"
30590
+ "Cache-Control": "no-cache, no-transform",
30591
+ Connection: "keep-alive",
30592
+ "X-Accel-Buffering": "no"
29881
30593
  };
29882
30594
  if (this.sessionId !== undefined) {
29883
30595
  headers["mcp-session-id"] = this.sessionId;
@@ -29888,6 +30600,9 @@ data:
29888
30600
  controller: streamController,
29889
30601
  encoder,
29890
30602
  cleanup: () => {
30603
+ if (keepAliveTimer !== undefined) {
30604
+ clearInterval(keepAliveTimer);
30605
+ }
29891
30606
  this._streamMapping.delete(streamId);
29892
30607
  try {
29893
30608
  streamController.close();
@@ -29897,19 +30612,33 @@ data:
29897
30612
  this._requestToStreamMapping.set(message.id, streamId);
29898
30613
  }
29899
30614
  }
29900
- await this.writePrimingEvent(streamController, encoder, streamId, clientProtocolVersion);
29901
- for (const message of messages) {
29902
- let closeSSEStream;
29903
- let closeStandaloneSSEStream;
29904
- if (isJSONRPCRequest(message) && this._eventStore && clientProtocolVersion >= "2025-11-25") {
29905
- closeSSEStream = () => {
29906
- this.closeSSEStream(message.id);
29907
- };
29908
- closeStandaloneSSEStream = () => {
29909
- this.closeStandaloneSSEStream();
29910
- };
30615
+ try {
30616
+ await this.writePrimingEvent(streamController, encoder, streamId, clientProtocolVersion);
30617
+ for (const message of messages) {
30618
+ let closeSSEStream;
30619
+ let closeStandaloneSSEStream;
30620
+ if (isJSONRPCRequest(message) && this._eventStore && clientProtocolVersion >= "2025-11-25") {
30621
+ closeSSEStream = () => {
30622
+ this.closeSSEStream(message.id);
30623
+ };
30624
+ closeStandaloneSSEStream = () => {
30625
+ this.closeStandaloneSSEStream();
30626
+ };
30627
+ }
30628
+ this.onmessage?.(message, { authInfo: options?.authInfo, requestInfo, closeSSEStream, closeStandaloneSSEStream });
29911
30629
  }
29912
- this.onmessage?.(message, { authInfo: options?.authInfo, requestInfo, closeSSEStream, closeStandaloneSSEStream });
30630
+ } catch (error2) {
30631
+ this._streamMapping.get(streamId)?.cleanup();
30632
+ this._resumableStreams.delete(streamId);
30633
+ for (const message of messages) {
30634
+ if (isJSONRPCRequest(message)) {
30635
+ this._requestToStreamMapping.delete(message.id);
30636
+ }
30637
+ }
30638
+ throw error2;
30639
+ }
30640
+ if (this._streamMapping.get(streamId)?.controller === streamController) {
30641
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
29913
30642
  }
29914
30643
  return new Response(readable, { status: 200, headers });
29915
30644
  } catch (error2) {
@@ -29926,9 +30655,12 @@ data:
29926
30655
  if (protocolError) {
29927
30656
  return protocolError;
29928
30657
  }
29929
- await Promise.resolve(this._onsessionclosed?.(this.sessionId));
29930
- await this.close();
29931
- return new Response(null, { status: 200 });
30658
+ try {
30659
+ await Promise.resolve(this._onsessionclosed?.(this.sessionId));
30660
+ return new Response(null, { status: 200 });
30661
+ } finally {
30662
+ await this.close();
30663
+ }
29932
30664
  }
29933
30665
  validateSession(req) {
29934
30666
  if (this.sessionIdGenerator === undefined) {
@@ -29958,11 +30690,16 @@ data:
29958
30690
  return;
29959
30691
  }
29960
30692
  async close() {
30693
+ if (this._closed) {
30694
+ return;
30695
+ }
30696
+ this._closed = true;
29961
30697
  this._streamMapping.forEach(({ cleanup }) => {
29962
30698
  cleanup();
29963
30699
  });
29964
30700
  this._streamMapping.clear();
29965
30701
  this._requestResponseMap.clear();
30702
+ this._resumableStreams.clear();
29966
30703
  this.onclose?.();
29967
30704
  }
29968
30705
  closeSSEStream(requestId) {
@@ -29997,7 +30734,7 @@ data:
29997
30734
  if (standaloneSse === undefined) {
29998
30735
  return;
29999
30736
  }
30000
- if (standaloneSse.controller && standaloneSse.encoder) {
30737
+ if (standaloneSse.controller && standaloneSse.encoder && (eventId === undefined || !standaloneSse.replayedEventIds?.has(eventId))) {
30001
30738
  this.writeSSEEvent(standaloneSse.controller, standaloneSse.encoder, message, eventId);
30002
30739
  }
30003
30740
  return;
@@ -30006,13 +30743,19 @@ data:
30006
30743
  if (!streamId) {
30007
30744
  throw new Error(`No connection established for request ID: ${String(requestId)}`);
30008
30745
  }
30009
- const stream = this._streamMapping.get(streamId);
30010
- if (!this._enableJsonResponse && stream?.controller && stream?.encoder) {
30746
+ let stream = this._streamMapping.get(streamId);
30747
+ if (!this._enableJsonResponse) {
30011
30748
  let eventId;
30012
30749
  if (this._eventStore) {
30013
30750
  eventId = await this._eventStore.storeEvent(streamId, message);
30751
+ stream = this._streamMapping.get(streamId);
30752
+ }
30753
+ if (stream?.controller && stream?.encoder && (eventId === undefined || !stream.replayedEventIds?.has(eventId))) {
30754
+ const written = this.writeSSEEvent(stream.controller, stream.encoder, message, eventId);
30755
+ if (written && eventId !== undefined) {
30756
+ this._resumableStreams.add(streamId);
30757
+ }
30014
30758
  }
30015
- this.writeSSEEvent(stream.controller, stream.encoder, message, eventId);
30016
30759
  }
30017
30760
  if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
30018
30761
  this._requestResponseMap.set(requestId, message);
@@ -30020,6 +30763,25 @@ data:
30020
30763
  const allResponsesReady = relatedIds.every((id) => this._requestResponseMap.has(id));
30021
30764
  if (allResponsesReady) {
30022
30765
  if (!stream) {
30766
+ if (this._closed) {
30767
+ for (const id of relatedIds) {
30768
+ this._requestResponseMap.delete(id);
30769
+ this._requestToStreamMapping.delete(id);
30770
+ }
30771
+ return;
30772
+ }
30773
+ if (!this._enableJsonResponse && this._eventStore && this._resumableStreams.has(streamId)) {
30774
+ for (const id of relatedIds) {
30775
+ this._requestResponseMap.delete(id);
30776
+ this._requestToStreamMapping.delete(id);
30777
+ }
30778
+ this._resumableStreams.delete(streamId);
30779
+ return;
30780
+ }
30781
+ for (const id of relatedIds) {
30782
+ this._requestResponseMap.delete(id);
30783
+ this._requestToStreamMapping.delete(id);
30784
+ }
30023
30785
  throw new Error(`No connection established for request ID: ${String(requestId)}`);
30024
30786
  }
30025
30787
  if (this._enableJsonResponse && stream.resolveJson) {
@@ -30042,6 +30804,7 @@ data:
30042
30804
  this._requestResponseMap.delete(id);
30043
30805
  this._requestToStreamMapping.delete(id);
30044
30806
  }
30807
+ this._resumableStreams.delete(streamId);
30045
30808
  }
30046
30809
  }
30047
30810
  }
@@ -30098,7 +30861,7 @@ function startMcpHttpServer(options) {
30098
30861
  // src/mcp/index.ts
30099
30862
  function getServerVersion() {
30100
30863
  try {
30101
- const packageJsonPath = join5(import.meta.dir, "..", "..", "package.json");
30864
+ const packageJsonPath = join7(import.meta.dir, "..", "..", "package.json");
30102
30865
  const pkg2 = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
30103
30866
  return pkg2.version ?? "0.0.0";
30104
30867
  } catch {