stateful-mcp 0.1.1

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 (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/config/about/dictionary.md +8 -0
  4. package/config/about/event.md +8 -0
  5. package/config/about/filter.md +9 -0
  6. package/config/about/form.md +9 -0
  7. package/config/about/log.md +9 -0
  8. package/config/about/middleware.md +18 -0
  9. package/config/about/object.md +8 -0
  10. package/config/about.config.json +37 -0
  11. package/config/examples/dictionary.md +9 -0
  12. package/config/examples/event.md +10 -0
  13. package/config/examples/filter.md +13 -0
  14. package/config/examples/form.md +23 -0
  15. package/config/examples/log.md +14 -0
  16. package/config/examples/object.md +12 -0
  17. package/config/storage.config.json +39 -0
  18. package/config/tools.config.json +14 -0
  19. package/dist/adapters/engines/dataframe-bridge.py +89 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +37412 -0
  23. package/dist/src/adapters/engines/dataframe-engine.d.ts +33 -0
  24. package/dist/src/adapters/engines/dataframe-engine.d.ts.map +1 -0
  25. package/dist/src/adapters/engines/interfaces.d.ts +11 -0
  26. package/dist/src/adapters/engines/interfaces.d.ts.map +1 -0
  27. package/dist/src/adapters/engines/memory-query.d.ts +12 -0
  28. package/dist/src/adapters/engines/memory-query.d.ts.map +1 -0
  29. package/dist/src/adapters/engines/pg-query.d.ts +16 -0
  30. package/dist/src/adapters/engines/pg-query.d.ts.map +1 -0
  31. package/dist/src/adapters/engines/sqlite-query.d.ts +16 -0
  32. package/dist/src/adapters/engines/sqlite-query.d.ts.map +1 -0
  33. package/dist/src/adapters/storage/browser-repo.d.ts +116 -0
  34. package/dist/src/adapters/storage/browser-repo.d.ts.map +1 -0
  35. package/dist/src/adapters/storage/compliance.d.ts +13 -0
  36. package/dist/src/adapters/storage/compliance.d.ts.map +1 -0
  37. package/dist/src/adapters/storage/interfaces.d.ts +134 -0
  38. package/dist/src/adapters/storage/interfaces.d.ts.map +1 -0
  39. package/dist/src/adapters/storage/jsonl-repo.d.ts +178 -0
  40. package/dist/src/adapters/storage/jsonl-repo.d.ts.map +1 -0
  41. package/dist/src/adapters/storage/memory-repo.d.ts +129 -0
  42. package/dist/src/adapters/storage/memory-repo.d.ts.map +1 -0
  43. package/dist/src/adapters/storage/pg-repo.d.ts +38 -0
  44. package/dist/src/adapters/storage/pg-repo.d.ts.map +1 -0
  45. package/dist/src/adapters/storage/sqlite-repo.d.ts +91 -0
  46. package/dist/src/adapters/storage/sqlite-repo.d.ts.map +1 -0
  47. package/dist/src/adapters/validation/references.d.ts +6 -0
  48. package/dist/src/adapters/validation/references.d.ts.map +1 -0
  49. package/dist/src/adapters/validation/runner.d.ts +28 -0
  50. package/dist/src/adapters/validation/runner.d.ts.map +1 -0
  51. package/dist/src/config/loader.d.ts +33 -0
  52. package/dist/src/config/loader.d.ts.map +1 -0
  53. package/dist/src/config/loader.js +232 -0
  54. package/dist/src/config/pagination.d.ts +44 -0
  55. package/dist/src/config/pagination.d.ts.map +1 -0
  56. package/dist/src/config/types.d.ts +152 -0
  57. package/dist/src/config/types.d.ts.map +1 -0
  58. package/dist/src/config/types.js +1 -0
  59. package/dist/src/config/validator.d.ts +3 -0
  60. package/dist/src/config/validator.d.ts.map +1 -0
  61. package/dist/src/errors/format.d.ts +8 -0
  62. package/dist/src/errors/format.d.ts.map +1 -0
  63. package/dist/src/errors/types.d.ts +32 -0
  64. package/dist/src/errors/types.d.ts.map +1 -0
  65. package/dist/src/errors/types.js +44 -0
  66. package/dist/src/middleware/dictionary/interfaces.d.ts +43 -0
  67. package/dist/src/middleware/dictionary/interfaces.d.ts.map +1 -0
  68. package/dist/src/middleware/dictionary/resolver.d.ts +47 -0
  69. package/dist/src/middleware/dictionary/resolver.d.ts.map +1 -0
  70. package/dist/src/middleware/dictionary/store.d.ts +73 -0
  71. package/dist/src/middleware/dictionary/store.d.ts.map +1 -0
  72. package/dist/src/middleware/dictionary/types.d.ts +152 -0
  73. package/dist/src/middleware/dictionary/types.d.ts.map +1 -0
  74. package/dist/src/middleware/event/store.d.ts +59 -0
  75. package/dist/src/middleware/event/store.d.ts.map +1 -0
  76. package/dist/src/middleware/event/types.d.ts +48 -0
  77. package/dist/src/middleware/event/types.d.ts.map +1 -0
  78. package/dist/src/middleware/filter/store.d.ts +44 -0
  79. package/dist/src/middleware/filter/store.d.ts.map +1 -0
  80. package/dist/src/middleware/filter/types.d.ts +65 -0
  81. package/dist/src/middleware/filter/types.d.ts.map +1 -0
  82. package/dist/src/middleware/form/store.d.ts +43 -0
  83. package/dist/src/middleware/form/store.d.ts.map +1 -0
  84. package/dist/src/middleware/form/types.d.ts +21 -0
  85. package/dist/src/middleware/form/types.d.ts.map +1 -0
  86. package/dist/src/middleware/object/schema-walker.d.ts +4 -0
  87. package/dist/src/middleware/object/schema-walker.d.ts.map +1 -0
  88. package/dist/src/middleware/object/store.d.ts +62 -0
  89. package/dist/src/middleware/object/store.d.ts.map +1 -0
  90. package/dist/src/middleware/object/types.d.ts +19 -0
  91. package/dist/src/middleware/object/types.d.ts.map +1 -0
  92. package/dist/src/services/dictionary.d.ts +2 -0
  93. package/dist/src/services/dictionary.d.ts.map +1 -0
  94. package/dist/src/services/event.d.ts +2 -0
  95. package/dist/src/services/event.d.ts.map +1 -0
  96. package/dist/src/services/filter.d.ts +2 -0
  97. package/dist/src/services/filter.d.ts.map +1 -0
  98. package/dist/src/services/form.d.ts +2 -0
  99. package/dist/src/services/form.d.ts.map +1 -0
  100. package/dist/src/services/helper.d.ts +8 -0
  101. package/dist/src/services/helper.d.ts.map +1 -0
  102. package/dist/src/services/log.d.ts +2 -0
  103. package/dist/src/services/log.d.ts.map +1 -0
  104. package/dist/src/services/object.d.ts +2 -0
  105. package/dist/src/services/object.d.ts.map +1 -0
  106. package/dist/src/translation/compiler.d.ts +3 -0
  107. package/dist/src/translation/compiler.d.ts.map +1 -0
  108. package/dist/src/translation/pipeline.d.ts +3 -0
  109. package/dist/src/translation/pipeline.d.ts.map +1 -0
  110. package/dist/src/translation/resolver.d.ts +4 -0
  111. package/dist/src/translation/resolver.d.ts.map +1 -0
  112. package/dist/src/translation/types.d.ts +32 -0
  113. package/dist/src/translation/types.d.ts.map +1 -0
  114. package/dist/src/translation/validator.d.ts +3 -0
  115. package/dist/src/translation/validator.d.ts.map +1 -0
  116. package/docs/browser.md +96 -0
  117. package/docs/config.md +498 -0
  118. package/docs/dictionary.md +37 -0
  119. package/docs/event.md +35 -0
  120. package/docs/filter.md +32 -0
  121. package/docs/log.md +54 -0
  122. package/docs/object.md +29 -0
  123. package/docs/pipeline.md +116 -0
  124. package/docs/resource_types.md +138 -0
  125. package/docs/validation_examples.md +230 -0
  126. package/package.json +91 -0
@@ -0,0 +1,152 @@
1
+ export type ResourceLocator = {
2
+ _type: "adapter";
3
+ name: string;
4
+ options?: Record<string, unknown>;
5
+ } | {
6
+ _type: "file";
7
+ path: string;
8
+ ttl_ms?: number;
9
+ } | {
10
+ _type: "remote_url";
11
+ url: string;
12
+ ttl_ms?: number;
13
+ headers?: Record<string, string>;
14
+ };
15
+ export type OwnerScope = {
16
+ level: "global";
17
+ } | {
18
+ level: "user";
19
+ userId: string;
20
+ };
21
+ export interface ToolConfig {
22
+ schema: ResourceLocator;
23
+ translation?: ResourceLocator;
24
+ engine: ResourceLocator | Record<string, ResourceLocator>;
25
+ validation_engine?: ResourceLocator;
26
+ inspect?: {
27
+ expose_compiled?: boolean;
28
+ };
29
+ }
30
+ export interface AutoCompressionConfig {
31
+ filter_chain_threshold?: number;
32
+ object_chain_threshold?: number;
33
+ }
34
+ export interface PaginationLimitsConfig {
35
+ /** Max entries per log page (log_open / log_next). */
36
+ log_page_size?: number;
37
+ /** Max examples returned per page by *_examples tools. */
38
+ examples_page_size?: number;
39
+ /** Max conflicts returned per page by event_merge_inspect. */
40
+ merge_conflicts_page_size?: number;
41
+ }
42
+ export interface MiddlewareConfig {
43
+ $schema?: string;
44
+ version: 1;
45
+ filter_session_state: ResourceLocator;
46
+ filter_persistent_state: {
47
+ global: ResourceLocator;
48
+ user: ResourceLocator;
49
+ };
50
+ object_session_state: ResourceLocator;
51
+ object_persistent_state: {
52
+ global: ResourceLocator;
53
+ user: ResourceLocator;
54
+ };
55
+ event_session_state?: ResourceLocator;
56
+ event_persistent_state?: {
57
+ global: ResourceLocator;
58
+ user: ResourceLocator;
59
+ };
60
+ form_session_state?: ResourceLocator;
61
+ form_persistent_state?: {
62
+ global: ResourceLocator;
63
+ user: ResourceLocator;
64
+ };
65
+ dictionary_state: ResourceLocator;
66
+ dictionary_resolver: ResourceLocator;
67
+ auto_compression?: AutoCompressionConfig;
68
+ constants?: {
69
+ global?: ResourceLocator;
70
+ user?: ResourceLocator;
71
+ };
72
+ object_schemas?: Record<string, ResourceLocator | {
73
+ schema: ResourceLocator;
74
+ validation_engine?: ResourceLocator;
75
+ }>;
76
+ object_schema_limits?: {
77
+ max_fields_per_def?: number;
78
+ max_ref_depth?: number;
79
+ };
80
+ pagination_limits?: PaginationLimitsConfig;
81
+ form_schemas?: Record<string, ResourceLocator | {
82
+ schema: ResourceLocator;
83
+ }>;
84
+ tools: Record<string, ToolConfig>;
85
+ env_sources?: Array<ResourceLocator & {
86
+ optional?: boolean;
87
+ }>;
88
+ about_and_examples?: AboutAndExamplesConfig;
89
+ }
90
+ export interface AboutAndExamplesConfig {
91
+ middleware_about?: ResourceLocator[];
92
+ filter_about?: ResourceLocator[];
93
+ filter_examples?: ResourceLocator[];
94
+ object_about?: ResourceLocator[];
95
+ object_examples?: ResourceLocator[];
96
+ dictionary_about?: ResourceLocator[];
97
+ dictionary_examples?: ResourceLocator[];
98
+ event_about?: ResourceLocator[];
99
+ event_examples?: ResourceLocator[];
100
+ form_about?: ResourceLocator[];
101
+ form_examples?: ResourceLocator[];
102
+ }
103
+ export interface TableSchema {
104
+ filterable_properties: string[];
105
+ operators: string[];
106
+ groupable_columns?: string[];
107
+ aggregations?: string[];
108
+ result_shape?: string;
109
+ max_results?: number;
110
+ mock_dataset?: any[];
111
+ }
112
+ export interface ToolSchema {
113
+ primary_table?: string;
114
+ available_tables: string[];
115
+ table_schemas: Record<string, TableSchema>;
116
+ }
117
+ export interface FormNextRule {
118
+ condition?: {
119
+ operator: string;
120
+ value: any;
121
+ };
122
+ target: string | null;
123
+ }
124
+ export interface FormQuestion {
125
+ text: string;
126
+ answer_type: "boolean" | "free_text" | "multiple_choice" | "scale" | "number" | "date" | "multi_select" | "ranked";
127
+ required?: boolean;
128
+ options?: string[];
129
+ scale?: {
130
+ min: number;
131
+ max: number;
132
+ step?: number;
133
+ };
134
+ next?: FormNextRule[] | {
135
+ default: string | null;
136
+ } | Record<string, string | null>;
137
+ }
138
+ export interface FormSection {
139
+ title: string;
140
+ questions: string[];
141
+ next?: {
142
+ default: string | null;
143
+ } | FormNextRule[];
144
+ }
145
+ export interface FormSchema {
146
+ form_id: string;
147
+ sections?: Record<string, FormSection>;
148
+ questions: Record<string, FormQuestion>;
149
+ start_section?: string;
150
+ start_question: string;
151
+ }
152
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,eAAe,GACvB;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACrE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAE5F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AAA;KAAE,CAAC;IACpD,IAAI,CAAC,EAAE,YAAY,EAAE,GAAG;QAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CACpF;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,YAAY,EAAE,CAAC;CACpD;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,3 @@
1
+ import type { MiddlewareConfig } from "./types";
2
+ export declare function validateMiddlewareConfig(config: any): asserts config is MiddlewareConfig;
3
+ //# sourceMappingURL=validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/config/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAA+B,MAAM,SAAS,CAAC;AA2B7E,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,IAAI,gBAAgB,CAwJxF"}
@@ -0,0 +1,8 @@
1
+ export declare function formatErrorResponse(err: unknown): {
2
+ content: {
3
+ type: string;
4
+ text: string;
5
+ }[];
6
+ isError: boolean;
7
+ };
8
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/errors/format.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO;;;;;;EAkC/C"}
@@ -0,0 +1,32 @@
1
+ export declare enum ErrorCode {
2
+ CONFIG_INVALID = "CONFIG_INVALID",
3
+ ADAPTER_NOT_REGISTERED = "ADAPTER_NOT_REGISTERED",
4
+ SCHEMA_LOAD_FAILED = "SCHEMA_LOAD_FAILED",
5
+ TRANSLATION_CYCLE = "TRANSLATION_CYCLE",
6
+ FILTER_NOT_FOUND = "FILTER_NOT_FOUND",
7
+ FILTER_PROPERTY_INVALID = "FILTER_PROPERTY_INVALID",
8
+ FILTER_OPERATOR_INVALID = "FILTER_OPERATOR_INVALID",
9
+ FILTER_COMBINATION_INVALID = "FILTER_COMBINATION_INVALID",
10
+ FILTER_SCOPE_INVALID = "FILTER_SCOPE_INVALID",
11
+ FILTER_PRIVILEGE_DENIED = "FILTER_PRIVILEGE_DENIED",
12
+ CONCEPT_NOT_FOUND = "CONCEPT_NOT_FOUND",
13
+ CONCEPT_ALLOCATION_FAILED = "CONCEPT_ALLOCATION_FAILED",
14
+ EXPRESSION_INVALID = "EXPRESSION_INVALID",
15
+ RESOLVE_NO_MATCH = "RESOLVE_NO_MATCH",
16
+ DICTIONARY_MUTATION_DENIED = "DICTIONARY_MUTATION_DENIED",
17
+ OBJECT_NOT_FOUND = "OBJECT_NOT_FOUND",
18
+ OBJECT_PATH_INVALID = "OBJECT_PATH_INVALID",
19
+ OBJECT_TYPE_MISMATCH = "OBJECT_TYPE_MISMATCH",
20
+ OBJECT_VALIDATION_FAILED = "OBJECT_VALIDATION_FAILED",
21
+ OBJECT_CYCLE_DETECTED = "OBJECT_CYCLE_DETECTED",
22
+ OBJECT_SCHEMA_EXCEEDED = "OBJECT_SCHEMA_EXCEEDED",
23
+ EXECUTION_FAILED = "EXECUTION_FAILED",
24
+ INTERNAL_ERROR = "INTERNAL_ERROR",
25
+ SCHEMA_MISMATCH = "SCHEMA_MISMATCH"
26
+ }
27
+ export declare class McpError extends Error {
28
+ readonly code: ErrorCode;
29
+ readonly details?: Record<string, unknown> | undefined;
30
+ constructor(code: ErrorCode, message: string, details?: Record<string, unknown> | undefined);
31
+ }
32
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/errors/types.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IAEnB,cAAc,mBAA8B;IAC5C,sBAAsB,2BAA8B;IACpD,kBAAkB,uBAA8B;IAChD,iBAAiB,sBAA8B;IAG/C,gBAAgB,qBAA8B;IAC9C,uBAAuB,4BAA8B;IACrD,uBAAuB,4BAA8B;IACrD,0BAA0B,+BAA+B;IACzD,oBAAoB,yBAA8B;IAClD,uBAAuB,4BAA8B;IAGrD,iBAAiB,sBAA8B;IAC/C,yBAAyB,8BAA8B;IACvD,kBAAkB,uBAA8B;IAChD,gBAAgB,qBAA8B;IAC9C,0BAA0B,+BAA+B;IAGzD,gBAAgB,qBAA8B;IAC9C,mBAAmB,wBAA8B;IACjD,oBAAoB,yBAA8B;IAClD,wBAAwB,6BAA8B;IACtD,qBAAqB,0BAA8B;IACnD,sBAAsB,2BAA8B;IAGpD,gBAAgB,qBAA8B;IAG9C,cAAc,mBAA8B;IAC5C,eAAe,oBAA8B;CAC9C;AAED,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,SAAS;aAEf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFjC,IAAI,EAAE,SAAS,EAC/B,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAKpD"}
@@ -0,0 +1,44 @@
1
+ // @bun
2
+ // src/errors/types.ts
3
+ var ErrorCode;
4
+ ((ErrorCode2) => {
5
+ ErrorCode2["CONFIG_INVALID"] = "CONFIG_INVALID";
6
+ ErrorCode2["ADAPTER_NOT_REGISTERED"] = "ADAPTER_NOT_REGISTERED";
7
+ ErrorCode2["SCHEMA_LOAD_FAILED"] = "SCHEMA_LOAD_FAILED";
8
+ ErrorCode2["TRANSLATION_CYCLE"] = "TRANSLATION_CYCLE";
9
+ ErrorCode2["FILTER_NOT_FOUND"] = "FILTER_NOT_FOUND";
10
+ ErrorCode2["FILTER_PROPERTY_INVALID"] = "FILTER_PROPERTY_INVALID";
11
+ ErrorCode2["FILTER_OPERATOR_INVALID"] = "FILTER_OPERATOR_INVALID";
12
+ ErrorCode2["FILTER_COMBINATION_INVALID"] = "FILTER_COMBINATION_INVALID";
13
+ ErrorCode2["FILTER_SCOPE_INVALID"] = "FILTER_SCOPE_INVALID";
14
+ ErrorCode2["FILTER_PRIVILEGE_DENIED"] = "FILTER_PRIVILEGE_DENIED";
15
+ ErrorCode2["CONCEPT_NOT_FOUND"] = "CONCEPT_NOT_FOUND";
16
+ ErrorCode2["CONCEPT_ALLOCATION_FAILED"] = "CONCEPT_ALLOCATION_FAILED";
17
+ ErrorCode2["EXPRESSION_INVALID"] = "EXPRESSION_INVALID";
18
+ ErrorCode2["RESOLVE_NO_MATCH"] = "RESOLVE_NO_MATCH";
19
+ ErrorCode2["DICTIONARY_MUTATION_DENIED"] = "DICTIONARY_MUTATION_DENIED";
20
+ ErrorCode2["OBJECT_NOT_FOUND"] = "OBJECT_NOT_FOUND";
21
+ ErrorCode2["OBJECT_PATH_INVALID"] = "OBJECT_PATH_INVALID";
22
+ ErrorCode2["OBJECT_TYPE_MISMATCH"] = "OBJECT_TYPE_MISMATCH";
23
+ ErrorCode2["OBJECT_VALIDATION_FAILED"] = "OBJECT_VALIDATION_FAILED";
24
+ ErrorCode2["OBJECT_CYCLE_DETECTED"] = "OBJECT_CYCLE_DETECTED";
25
+ ErrorCode2["OBJECT_SCHEMA_EXCEEDED"] = "OBJECT_SCHEMA_EXCEEDED";
26
+ ErrorCode2["EXECUTION_FAILED"] = "EXECUTION_FAILED";
27
+ ErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
28
+ ErrorCode2["SCHEMA_MISMATCH"] = "SCHEMA_MISMATCH";
29
+ })(ErrorCode ||= {});
30
+
31
+ class McpError extends Error {
32
+ code;
33
+ details;
34
+ constructor(code, message, details) {
35
+ super(message);
36
+ this.code = code;
37
+ this.details = details;
38
+ this.name = "McpError";
39
+ }
40
+ }
41
+ export {
42
+ McpError,
43
+ ErrorCode
44
+ };
@@ -0,0 +1,43 @@
1
+ import type { Concept, CustomExpression, Namespace } from "./types";
2
+ import type { OwnerScope } from "../../config/types";
3
+ export interface ConceptStore {
4
+ /**
5
+ * Search concepts by term, matching ID, code, display, or description.
6
+ */
7
+ search(query: string, namespaceCode?: string, limit?: number): Promise<Concept[]>;
8
+ /**
9
+ * Retrieve a single concept by ID.
10
+ */
11
+ getById(id: string): Promise<Concept | null>;
12
+ /**
13
+ * List all namespaces.
14
+ */
15
+ listNamespaces(): Promise<Namespace[]>;
16
+ /**
17
+ * Optional helper to add concepts (for setup and compliance testing).
18
+ */
19
+ addConcept(concept: Concept): Promise<void>;
20
+ /**
21
+ * Optional helper to add namespaces.
22
+ */
23
+ addNamespace(namespace: Namespace): Promise<void>;
24
+ }
25
+ export interface PersistentExpressionStore {
26
+ /**
27
+ * Save a custom abbreviation/expression in the database.
28
+ */
29
+ save(expression: CustomExpression, scope: OwnerScope): Promise<void>;
30
+ /**
31
+ * Delete a custom expression from the database.
32
+ */
33
+ delete(id: string, scope: OwnerScope): Promise<void>;
34
+ /**
35
+ * List all custom expressions visible to this scope.
36
+ */
37
+ list(scope: OwnerScope, includeGlobal?: boolean): Promise<CustomExpression[]>;
38
+ /**
39
+ * Retrieve a single custom expression by ID (for permission/existence checking).
40
+ */
41
+ getById(id: string): Promise<CustomExpression | null>;
42
+ }
43
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/middleware/dictionary/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAElF;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAE7C;;OAEG;IACH,cAAc,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAEvC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,IAAI,CAAC,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErE;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErD;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAE9E;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACvD"}
@@ -0,0 +1,47 @@
1
+ import type { Concept, CustomExpression, ResolutionMetric } from "./types";
2
+ import type { ConceptStore, PersistentExpressionStore } from "./interfaces";
3
+ export type ResolutionStatus = 'FOUND' | 'PARTIAL' | 'NOT_FOUND';
4
+ export interface AggregatedResult {
5
+ conceptId: string;
6
+ concept: Concept;
7
+ score: number;
8
+ matchedTerms: string[];
9
+ sources: string[];
10
+ }
11
+ export interface ResolveResponse {
12
+ status: ResolutionStatus;
13
+ sources: string[];
14
+ results: AggregatedResult[];
15
+ }
16
+ export interface ResolveResult {
17
+ conceptId: string;
18
+ concept: Concept;
19
+ expression: CustomExpression;
20
+ score: number;
21
+ }
22
+ export interface ConceptResolver {
23
+ resolve(term: string, concepts: ConceptStore | Map<string, Concept>, expressions: PersistentExpressionStore | CustomExpression[], metrics: ResolutionMetric[], context?: Record<string, any>): Promise<ResolveResponse>;
24
+ }
25
+ export declare class InMemoryConceptResolver implements ConceptResolver {
26
+ private getExpressionScopeLevel;
27
+ private getExpressionScopeLevelNumeric;
28
+ private matchesContext;
29
+ resolve(term: string, concepts: ConceptStore | Map<string, Concept>, expressions: PersistentExpressionStore | CustomExpression[], metrics: ResolutionMetric[], context?: Record<string, any>): Promise<ResolveResponse>;
30
+ }
31
+ import type { BackendWeightConfig } from "./types";
32
+ export interface BackendInstance {
33
+ config: BackendWeightConfig;
34
+ currentWeight: number;
35
+ resolver: ConceptResolver;
36
+ concepts: Map<string, Concept>;
37
+ expressions: CustomExpression[];
38
+ metrics: ResolutionMetric[];
39
+ }
40
+ export declare class MultiBackendConceptResolver implements ConceptResolver {
41
+ private backends;
42
+ constructor(backends: BackendInstance[]);
43
+ getBackends(): BackendInstance[];
44
+ adjustWeight(backendId: string, adjustment: number): void;
45
+ resolve(term: string, concepts: Map<string, Concept>, expressions: CustomExpression[], metrics: ResolutionMetric[], context?: Record<string, any>): Promise<ResolveResponse>;
46
+ }
47
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../src/middleware/dictionary/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OA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,yBAAyB,GAAG,gBAAgB,EAAE,EAC3D,OAAO,EAAE,gBAAgB,EAAE,EAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,OAAO,CAAC,eAAe,CAAC;CA2G5B;AAED,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED,qBAAa,2BAA4B,YAAW,eAAe;IACrD,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,eAAe,EAAE;IAExC,WAAW,IAAI,eAAe,EAAE;IAIhC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAc5C,OAAO,CAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,WAAW,EAAE,gBAAgB,EAAE,EAC/B,OAAO,EAAE,gBAAgB,EAAE,EAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,OAAO,CAAC,eAAe,CAAC;CAyF5B"}
@@ -0,0 +1,73 @@
1
+ import type { Namespace, Concept, ConceptRelation, CustomExpression, ResolutionMetric, DictionaryConfig, WorkspaceDefinition } from "./types";
2
+ import type { ConceptResolver } from "./resolver";
3
+ import type { ConceptStore, PersistentExpressionStore } from "./interfaces";
4
+ import type { OwnerScope } from "../../config/types";
5
+ export declare class InMemoryConceptStore implements ConceptStore {
6
+ private namespaces;
7
+ private concepts;
8
+ search(query: string, namespaceCode?: string, limit?: number): Promise<Concept[]>;
9
+ getById(id: string): Promise<Concept | null>;
10
+ listNamespaces(): Promise<Namespace[]>;
11
+ addConcept(concept: Concept): Promise<void>;
12
+ addNamespace(namespace: Namespace): Promise<void>;
13
+ }
14
+ export declare class InMemoryPersistentExpressionStore implements PersistentExpressionStore {
15
+ private expressions;
16
+ save(expression: CustomExpression, scope: OwnerScope): Promise<void>;
17
+ delete(id: string, scope: OwnerScope): Promise<void>;
18
+ list(scope: OwnerScope, includeGlobal?: boolean): Promise<CustomExpression[]>;
19
+ getById(id: string): Promise<CustomExpression | null>;
20
+ }
21
+ export declare class DictionaryStore {
22
+ private resolver;
23
+ private conceptStore;
24
+ private expressionStore;
25
+ private relations;
26
+ private metrics;
27
+ private allowedTargetAssignments?;
28
+ private workspaces;
29
+ private allowedTags?;
30
+ private exposeTagsAsEnum;
31
+ private defaultDynamicNamespace;
32
+ private defaultWorkspaceId;
33
+ private exposeWorkspaceAsEnum;
34
+ constructor(resolver: ConceptResolver, conceptStore?: ConceptStore, expressionStore?: PersistentExpressionStore);
35
+ loadConfig(config: DictionaryConfig): Promise<void>;
36
+ shouldExposeWorkspaceAsEnum(): boolean;
37
+ getDefaultWorkspace(): string;
38
+ getWorkspaces(): WorkspaceDefinition[];
39
+ resolveConceptId(ref: string): Promise<string | undefined>;
40
+ getAllowedTags(): string[];
41
+ shouldExposeTagsAsEnum(): boolean;
42
+ getDefaultDynamicNamespace(): string;
43
+ addNamespace(ns: Namespace): Promise<void>;
44
+ getNamespace(code: string): Promise<Namespace | undefined>;
45
+ private verifyNamespaceMutable;
46
+ private checkScopeAccess;
47
+ addConcept(c: Omit<Concept, "id"> & {
48
+ id?: string;
49
+ }): Promise<string>;
50
+ editConcept(id: string, updates: Partial<Concept>, callerContext?: Record<string, any>): Promise<void>;
51
+ removeConcept(id: string, callerContext?: Record<string, any>): Promise<void>;
52
+ getConcept(id: string): Promise<Concept | undefined>;
53
+ addRelation(rel: ConceptRelation): Promise<void>;
54
+ removeRelation(id: string, callerContext?: Record<string, any>): Promise<void>;
55
+ getRelations(): ConceptRelation[];
56
+ addExpression(expr: Omit<CustomExpression, "id"> & {
57
+ id?: string;
58
+ }, callerContext?: Record<string, any>): Promise<string>;
59
+ editExpression(id: string, updates: Partial<CustomExpression>, callerContext?: Record<string, any>): Promise<void>;
60
+ removeExpression(id: string, callerContext?: Record<string, any>): Promise<boolean>;
61
+ getExpressions(scope?: OwnerScope): Promise<CustomExpression[]>;
62
+ private getExpressionScopeLevel;
63
+ private matchesContext;
64
+ resolve(term: string, context?: Record<string, any>): Promise<any>;
65
+ find(query: {
66
+ term?: string;
67
+ tags?: string[];
68
+ conceptType?: string;
69
+ }, context?: Record<string, any>): Promise<CustomExpression[]>;
70
+ recordUsage(expressionId: string, conceptId: string, context: Record<string, any>): void;
71
+ getMetrics(): ResolutionMetric[];
72
+ }
73
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/middleware/dictionary/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,QAAQ,CAA8B;IAExC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAkBrF,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CA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** Unique classification code for the namespace (e.g., 'SNOMED', 'ICD-10') */
6
+ code: string;
7
+ /** Human-readable explanation of the terminology database scope */
8
+ description?: string;
9
+ /** If true, the namespace is openly queryable by any user or context */
10
+ isPublic: boolean;
11
+ /** If true, data resides in an external private store requiring authentication */
12
+ isExternalPrivate: boolean;
13
+ /** If true, user can add/edit/remove entries in this namespace */
14
+ isMutable?: boolean;
15
+ /** Identifier/name of the private database or integration connector */
16
+ externalPrivateSource?: string;
17
+ /** Endpoint URL for external REST/GraphQL concept lookup APIs */
18
+ apiUrl?: string;
19
+ /** Static query string parameters or path segments for the lookup request */
20
+ apiUrlParams?: Record<string, any>;
21
+ /** Default request body JSON payload structure sent to the external API */
22
+ apiRequestPayload?: Record<string, any>;
23
+ /** JSON-path mapping key to retrieve the display name from the API JSON response */
24
+ apiResponseDisplayPath?: string;
25
+ }
26
+ /**
27
+ * Represents a single canonical concept or standard code coordinate within a coding system.
28
+ */
29
+ export interface Concept {
30
+ /** Unique concept ID (e.g., UUID) */
31
+ id: string;
32
+ /** The namespace identifier this concept belongs to (e.g., 'SNOMED') */
33
+ namespaceCode: string;
34
+ /** The canonical coordinate/code value (e.g., 'I21.9' or 'R06.02') */
35
+ standardCode: string;
36
+ /** Default user-friendly fallback display label for the concept code */
37
+ display: string;
38
+ /** Semantic description or clinical explanation of the concept definition */
39
+ description?: string;
40
+ /** Optional date stamp indicating when the concept was assigned or declared */
41
+ designationDate?: string;
42
+ /** If false, the concept is deactivated and ignored during resolution */
43
+ active?: boolean;
44
+ }
45
+ /** Semantic mapping relationships linking two different concepts */
46
+ export type ConceptRelationType = 'EQUIVALENT' | 'NARROWER_THAN' | 'WIDER_THAN';
47
+ /**
48
+ * Declares relationships between two different concepts (e.g. mapping synonyms or hierarchies).
49
+ */
50
+ export interface ConceptRelation {
51
+ /** Unique relationship record identifier */
52
+ id: string;
53
+ /** Source concept ID in the relationship */
54
+ conceptId: string;
55
+ /** Target concept ID linked to the source concept */
56
+ linkedId: string;
57
+ /** The semantic nature of the link (e.g., EQUIVALENT mapping) */
58
+ relationshipType: ConceptRelationType;
59
+ /** If false, the relation link is disabled and ignored */
60
+ active: boolean;
61
+ /** Optional date stamp of when the relationship was designated */
62
+ designationDate?: string;
63
+ }
64
+ /** Classification defining the type of target assignment (e.g. 'MAIN_TERM' or 'METRIC') */
65
+ export type TargetAssignment = string;
66
+ /**
67
+ * Defines a custom keyword pattern or alias mapping to map shorthand terms to concepts.
68
+ */
69
+ export interface CustomExpression {
70
+ /** Unique expression mapping record identifier */
71
+ id: string;
72
+ /** Default readable shorthand term or alias (e.g. 'heart attack') */
73
+ term: string;
74
+ /** Regex pattern compiled dynamically to evaluate match candidates */
75
+ regexPattern: string;
76
+ /** If true, regex matches ignore letter casing (case-insensitive flag) */
77
+ isCaseInsensitive: boolean;
78
+ /** Domain-specific role/assignment classification for this expression */
79
+ targetAssignment: TargetAssignment;
80
+ /** The target Concept ID this expression resolves/maps to */
81
+ conceptId?: string;
82
+ /** Static base scoring priority (higher values rank higher) */
83
+ priorityWeight: number;
84
+ /** If false, the expression mapping is ignored during resolution */
85
+ active: boolean;
86
+ /** Custom generic metadata dictionary (e.g. tags, workspace_id, description) */
87
+ context?: Record<string, any>;
88
+ }
89
+ /**
90
+ * Tracks historical statistics and metrics for resolved expressions.
91
+ */
92
+ export interface ResolutionMetric {
93
+ /** The custom expression ID that was successfully matched */
94
+ expressionId: string;
95
+ /** The concept ID that the expression resolved to */
96
+ conceptId: string;
97
+ /** Session/workspace context under which resolution took place */
98
+ context: Record<string, any>;
99
+ /** Total number of times this specific resolution mapping has been used */
100
+ usageCount: number;
101
+ /** ISO timestamp of the last successful resolution of this mapping */
102
+ lastResolvedAt: string;
103
+ }
104
+ export interface WorkspaceDefinition {
105
+ /** Unique workspace identifier code */
106
+ id: string;
107
+ /** Human-friendly name of the workspace */
108
+ name: string;
109
+ /** Detailed description of this workspace's purpose */
110
+ description?: string;
111
+ }
112
+ /**
113
+ * Configuration payload containing lists of initial dictionary elements to load.
114
+ */
115
+ export interface DictionaryConfig {
116
+ /** List of predefined terminology namespaces to populate */
117
+ namespaces?: Namespace[];
118
+ /** List of pre-seeded canonical concepts to load */
119
+ concepts?: Concept[];
120
+ /** List of semantic concept relationships to configure */
121
+ relations?: ConceptRelation[];
122
+ /** Pre-seeded shorthand-to-concept expression mappings */
123
+ expressions?: CustomExpression[];
124
+ /** List of allowed values for targetAssignment validation */
125
+ allowedTargetAssignments?: string[];
126
+ /** The default namespace identifier used for newly registered dynamic concepts */
127
+ defaultDynamicNamespace?: string;
128
+ /** Predefined set of valid workspace scopes */
129
+ workspaces?: WorkspaceDefinition[];
130
+ /** Predefined set of allowed entry tags */
131
+ allowedTags?: string[];
132
+ /** Flag to determine whether valid tags should be strictly exposed as an enum to the LLM */
133
+ exposeTagsAsEnum?: boolean;
134
+ /** The default workspace ID assigned when no workspace context is provided */
135
+ defaultWorkspaceId?: string;
136
+ /** Flag to determine whether valid workspaces should be strictly exposed as an enum to the LLM */
137
+ exposeWorkspaceAsEnum?: boolean;
138
+ }
139
+ /**
140
+ * Weight boundary configurations for a single dictionary resolution source.
141
+ */
142
+ export interface BackendWeightConfig {
143
+ /** Unique identifier for the resolution backend (e.g., 'personal', 'global') */
144
+ id: string;
145
+ /** Default scaling multiplier applied to candidate match scores */
146
+ defaultWeight: number;
147
+ /** Lower limit boundary preventing weight decay from dropping below a threshold */
148
+ minWeight?: number;
149
+ /** Upper limit boundary capping maximum weight growth on rewards */
150
+ maxWeight?: number;
151
+ }
152
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/middleware/dictionary/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,QAAQ,EAAE,OAAO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