@ifc-lite/mcp 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +186 -0
  3. package/dist/auth/index.d.ts +3 -0
  4. package/dist/auth/index.d.ts.map +1 -0
  5. package/dist/auth/index.js +5 -0
  6. package/dist/auth/index.js.map +1 -0
  7. package/dist/auth/scope.d.ts +24 -0
  8. package/dist/auth/scope.d.ts.map +1 -0
  9. package/dist/auth/scope.js +26 -0
  10. package/dist/auth/scope.js.map +1 -0
  11. package/dist/browser.d.ts +37 -0
  12. package/dist/browser.d.ts.map +1 -0
  13. package/dist/browser.js +37 -0
  14. package/dist/browser.js.map +1 -0
  15. package/dist/cli.d.ts +3 -0
  16. package/dist/cli.d.ts.map +1 -0
  17. package/dist/cli.js +233 -0
  18. package/dist/cli.js.map +1 -0
  19. package/dist/context.d.ts +87 -0
  20. package/dist/context.d.ts.map +1 -0
  21. package/dist/context.js +41 -0
  22. package/dist/context.js.map +1 -0
  23. package/dist/errors.d.ts +37 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/errors.js +49 -0
  26. package/dist/errors.js.map +1 -0
  27. package/dist/headless-backend.d.ts +61 -0
  28. package/dist/headless-backend.d.ts.map +1 -0
  29. package/dist/headless-backend.js +472 -0
  30. package/dist/headless-backend.js.map +1 -0
  31. package/dist/index.d.ts +39 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +49 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/loader.d.ts +9 -0
  36. package/dist/loader.d.ts.map +1 -0
  37. package/dist/loader.js +76 -0
  38. package/dist/loader.js.map +1 -0
  39. package/dist/prompts/index.d.ts +6 -0
  40. package/dist/prompts/index.d.ts.map +1 -0
  41. package/dist/prompts/index.js +13 -0
  42. package/dist/prompts/index.js.map +1 -0
  43. package/dist/prompts/templates.d.ts +21 -0
  44. package/dist/prompts/templates.d.ts.map +1 -0
  45. package/dist/prompts/templates.js +238 -0
  46. package/dist/prompts/templates.js.map +1 -0
  47. package/dist/prompts/types.d.ts +17 -0
  48. package/dist/prompts/types.d.ts.map +1 -0
  49. package/dist/prompts/types.js +27 -0
  50. package/dist/prompts/types.js.map +1 -0
  51. package/dist/protocol/index.d.ts +3 -0
  52. package/dist/protocol/index.d.ts.map +1 -0
  53. package/dist/protocol/index.js +6 -0
  54. package/dist/protocol/index.js.map +1 -0
  55. package/dist/protocol/jsonrpc.d.ts +12 -0
  56. package/dist/protocol/jsonrpc.d.ts.map +1 -0
  57. package/dist/protocol/jsonrpc.js +62 -0
  58. package/dist/protocol/jsonrpc.js.map +1 -0
  59. package/dist/protocol/types.d.ts +223 -0
  60. package/dist/protocol/types.d.ts.map +1 -0
  61. package/dist/protocol/types.js +37 -0
  62. package/dist/protocol/types.js.map +1 -0
  63. package/dist/resources/index.d.ts +6 -0
  64. package/dist/resources/index.d.ts.map +1 -0
  65. package/dist/resources/index.js +13 -0
  66. package/dist/resources/index.js.map +1 -0
  67. package/dist/resources/providers.d.ts +3 -0
  68. package/dist/resources/providers.d.ts.map +1 -0
  69. package/dist/resources/providers.js +270 -0
  70. package/dist/resources/providers.js.map +1 -0
  71. package/dist/resources/types.d.ts +29 -0
  72. package/dist/resources/types.d.ts.map +1 -0
  73. package/dist/resources/types.js +30 -0
  74. package/dist/resources/types.js.map +1 -0
  75. package/dist/server.d.ts +93 -0
  76. package/dist/server.d.ts.map +1 -0
  77. package/dist/server.js +396 -0
  78. package/dist/server.js.map +1 -0
  79. package/dist/tools/bcf.d.ts +3 -0
  80. package/dist/tools/bcf.d.ts.map +1 -0
  81. package/dist/tools/bcf.js +208 -0
  82. package/dist/tools/bcf.js.map +1 -0
  83. package/dist/tools/bsdd.d.ts +3 -0
  84. package/dist/tools/bsdd.d.ts.map +1 -0
  85. package/dist/tools/bsdd.js +267 -0
  86. package/dist/tools/bsdd.js.map +1 -0
  87. package/dist/tools/diff.d.ts +3 -0
  88. package/dist/tools/diff.d.ts.map +1 -0
  89. package/dist/tools/diff.js +149 -0
  90. package/dist/tools/diff.js.map +1 -0
  91. package/dist/tools/discovery.d.ts +8 -0
  92. package/dist/tools/discovery.d.ts.map +1 -0
  93. package/dist/tools/discovery.js +181 -0
  94. package/dist/tools/discovery.js.map +1 -0
  95. package/dist/tools/export.d.ts +3 -0
  96. package/dist/tools/export.d.ts.map +1 -0
  97. package/dist/tools/export.js +157 -0
  98. package/dist/tools/export.js.map +1 -0
  99. package/dist/tools/geometry.d.ts +3 -0
  100. package/dist/tools/geometry.d.ts.map +1 -0
  101. package/dist/tools/geometry.js +252 -0
  102. package/dist/tools/geometry.js.map +1 -0
  103. package/dist/tools/ids-accessor.d.ts +9 -0
  104. package/dist/tools/ids-accessor.d.ts.map +1 -0
  105. package/dist/tools/ids-accessor.js +131 -0
  106. package/dist/tools/ids-accessor.js.map +1 -0
  107. package/dist/tools/index.d.ts +21 -0
  108. package/dist/tools/index.d.ts.map +1 -0
  109. package/dist/tools/index.js +36 -0
  110. package/dist/tools/index.js.map +1 -0
  111. package/dist/tools/mutate.d.ts +3 -0
  112. package/dist/tools/mutate.d.ts.map +1 -0
  113. package/dist/tools/mutate.js +350 -0
  114. package/dist/tools/mutate.js.map +1 -0
  115. package/dist/tools/query.d.ts +3 -0
  116. package/dist/tools/query.d.ts.map +1 -0
  117. package/dist/tools/query.js +549 -0
  118. package/dist/tools/query.js.map +1 -0
  119. package/dist/tools/types.d.ts +18 -0
  120. package/dist/tools/types.d.ts.map +1 -0
  121. package/dist/tools/types.js +26 -0
  122. package/dist/tools/types.js.map +1 -0
  123. package/dist/tools/util.d.ts +19 -0
  124. package/dist/tools/util.d.ts.map +1 -0
  125. package/dist/tools/util.js +53 -0
  126. package/dist/tools/util.js.map +1 -0
  127. package/dist/tools/validation.d.ts +3 -0
  128. package/dist/tools/validation.d.ts.map +1 -0
  129. package/dist/tools/validation.js +244 -0
  130. package/dist/tools/validation.js.map +1 -0
  131. package/dist/tools/viewer.d.ts +3 -0
  132. package/dist/tools/viewer.d.ts.map +1 -0
  133. package/dist/tools/viewer.js +651 -0
  134. package/dist/tools/viewer.js.map +1 -0
  135. package/dist/transport/http.d.ts +64 -0
  136. package/dist/transport/http.d.ts.map +1 -0
  137. package/dist/transport/http.js +268 -0
  138. package/dist/transport/http.js.map +1 -0
  139. package/dist/transport/in-process.d.ts +25 -0
  140. package/dist/transport/in-process.d.ts.map +1 -0
  141. package/dist/transport/in-process.js +48 -0
  142. package/dist/transport/in-process.js.map +1 -0
  143. package/dist/transport/stdio.d.ts +33 -0
  144. package/dist/transport/stdio.d.ts.map +1 -0
  145. package/dist/transport/stdio.js +86 -0
  146. package/dist/transport/stdio.js.map +1 -0
  147. package/dist/validate.d.ts +23 -0
  148. package/dist/validate.d.ts.map +1 -0
  149. package/dist/validate.js +88 -0
  150. package/dist/validate.js.map +1 -0
  151. package/dist/viewer-manager.d.ts +51 -0
  152. package/dist/viewer-manager.d.ts.map +1 -0
  153. package/dist/viewer-manager.js +183 -0
  154. package/dist/viewer-manager.js.map +1 -0
  155. package/package.json +86 -0
package/dist/loader.js ADDED
@@ -0,0 +1,76 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ /**
5
+ * IFC file loader for the MCP server. Wraps `IfcParser.parseColumnar`,
6
+ * mounts a `HeadlessLikeBackend` on top of the resulting `IfcDataStore`,
7
+ * and produces a `LoadedModel` ready to drop into the registry.
8
+ *
9
+ * We don't pull in `@ifc-lite/cli`'s `HeadlessBackend` directly because that
10
+ * package depends on `@ifc-lite/viewer-core` which is browser-shaped. Instead
11
+ * we re-implement the small subset of `BimBackend` the MCP tools actually use
12
+ * (model + query + selection + spatial + export + mutate). All the renderer
13
+ * methods are no-ops, which is fine — agents never call them through MCP.
14
+ */
15
+ import { readFile } from 'node:fs/promises';
16
+ import { basename, resolve } from 'node:path';
17
+ import { IfcParser } from '@ifc-lite/parser';
18
+ import { createBimContext } from '@ifc-lite/sdk';
19
+ import { HeadlessLikeBackend } from './headless-backend.js';
20
+ export async function loadIfcModel(filePath, opts = {}) {
21
+ const absolute = resolve(filePath);
22
+ if (opts.allowedPaths && opts.allowedPaths.length > 0) {
23
+ const ok = opts.allowedPaths.some((p) => absolute === p || absolute.startsWith(p + '/'));
24
+ if (!ok) {
25
+ throw new Error(`Path '${absolute}' is outside the allowed roots`);
26
+ }
27
+ }
28
+ const buffer = await readFile(absolute);
29
+ if (buffer.byteLength === 0) {
30
+ throw new Error(`'${absolute}' is empty (0 bytes)`);
31
+ }
32
+ // Cheap signature check; full parser also bails on malformed STEP.
33
+ const headerSnippet = buffer.subarray(0, Math.min(buffer.byteLength, 256)).toString('ascii');
34
+ if (!headerSnippet.includes('ISO-10303-21')) {
35
+ throw new Error(`'${absolute}' is not a valid IFC/STEP file`);
36
+ }
37
+ const parser = new IfcParser();
38
+ // The parser writes progress to console.* — silence it during MCP loads
39
+ // so the JSON-RPC channel on stdout isn't polluted.
40
+ const origLog = console.log;
41
+ const origWarn = console.warn;
42
+ console.log = () => undefined;
43
+ console.warn = () => undefined;
44
+ let store;
45
+ try {
46
+ const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
47
+ store = await parser.parseColumnar(arrayBuffer);
48
+ store.fileSize = buffer.byteLength;
49
+ }
50
+ finally {
51
+ console.log = origLog;
52
+ console.warn = origWarn;
53
+ }
54
+ const id = opts.modelId ?? deriveModelId(basename(absolute));
55
+ const backend = new HeadlessLikeBackend(store, basename(absolute), id);
56
+ const bim = createBimContext({ backend });
57
+ return {
58
+ id,
59
+ name: basename(absolute),
60
+ bim,
61
+ store,
62
+ backend,
63
+ filePath: absolute,
64
+ loadedAt: Date.now(),
65
+ };
66
+ }
67
+ function deriveModelId(name) {
68
+ // Strip extension, replace spaces with underscores, lowercase. Keeps the
69
+ // ID URL-safe so it round-trips through `Mcp-Session-Id` headers and
70
+ // resource URIs.
71
+ return name
72
+ .replace(/\.(ifc|ifcxml|ifczip)$/i, '')
73
+ .replace(/[^a-zA-Z0-9_-]+/g, '_')
74
+ .toLowerCase() || 'model';
75
+ }
76
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAqB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAS5D,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,OAAuB,EAAE;IAC5E,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,KAAK,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzF,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,gCAAgC,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI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mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;IACvE,MAAM,GAAG,GAAe,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEtD,OAAO;QACL,EAAE;QACF,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC;QACxB,GAAG;QACH,KAAK;QACL,OAAO;QACP,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE;KACrB,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,yEAAyE;IACzE,qEAAqE;IACrE,iBAAiB;IACjB,OAAO,IAAI;SACR,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC;SACtC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC;SAChC,WAAW,EAAE,IAAI,OAAO,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { PromptRegistry } from './types.js';
2
+ export { PromptRegistry } from './types.js';
3
+ export type { Prompt } from './types.js';
4
+ export { allPrompts } from './templates.js';
5
+ export declare function buildDefaultPromptRegistry(): PromptRegistry;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,0BAA0B,IAAI,cAAc,CAI3D"}
@@ -0,0 +1,13 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ import { PromptRegistry } from './types.js';
5
+ import { allPrompts } from './templates.js';
6
+ export { PromptRegistry } from './types.js';
7
+ export { allPrompts } from './templates.js';
8
+ export function buildDefaultPromptRegistry() {
9
+ const registry = new PromptRegistry();
10
+ registry.registerAll(allPrompts);
11
+ return registry;
12
+ }
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,0BAA0B;IACxC,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACjC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Pre-baked prompt templates (spec §9). The aim is the same as Claude
3
+ * Code's slash commands: package the "BIM expert" intent + the right tool
4
+ * sequence so a non-power user gets a useful answer in one click.
5
+ *
6
+ * Templates are pure text — no eval, no interpolation beyond `${arg}`.
7
+ */
8
+ import type { Prompt } from './types.js';
9
+ export declare const auditModel: Prompt;
10
+ export declare const findFireRatedDoors: Prompt;
11
+ export declare const generateBcfFromIds: Prompt;
12
+ export declare const compareVersions: Prompt;
13
+ export declare const spaceProgramCheck: Prompt;
14
+ export declare const clashReview: Prompt;
15
+ export declare const propQualityPass: Prompt;
16
+ export declare const migrateToIfcx: Prompt;
17
+ export declare const visualAudit: Prompt;
18
+ export declare const interactivePropertyInspect: Prompt;
19
+ export declare const visualizeQuery: Prompt;
20
+ export declare const allPrompts: Prompt[];
21
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAUzC,eAAO,MAAM,UAAU,EAAE,MAuBxB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAsBhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAqBhC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAkB7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,MAgB/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAWzB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAkB7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAiB3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAqBzB,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,MAkBxC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,MAuB5B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAAM,EAY9B,CAAC"}
@@ -0,0 +1,238 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ function userMessage(text) {
5
+ return { role: 'user', content: { type: 'text', text } };
6
+ }
7
+ function systemMessage(text) {
8
+ return { role: 'system', content: { type: 'text', text } };
9
+ }
10
+ export const auditModel = {
11
+ name: 'audit_model',
12
+ description: 'Run the model_audit tool and explain the top issues by impact, suggesting fixes.',
13
+ arguments: [{ name: 'model_id', description: 'Optional explicit model id.', required: false }],
14
+ render(args) {
15
+ return {
16
+ description: 'Comprehensive model health check',
17
+ messages: [
18
+ systemMessage('You are a senior BIM modeler reviewing IFC quality.'),
19
+ userMessage([
20
+ 'Run `model_audit` on the loaded model',
21
+ args.model_id ? ` (model_id="${args.model_id}")` : '',
22
+ '. For each ERROR-severity issue, explain in plain language: ',
23
+ ' • what the issue means for downstream tools (clash, IDS, takeoff), ',
24
+ ' • why it usually happens, ',
25
+ ' • a concrete one-line fix the modeler can apply (which tool to call, with what arguments). ',
26
+ 'Group warnings by category and only call them out individually if they affect more than 5% of entities.',
27
+ ].join('')),
28
+ ],
29
+ };
30
+ },
31
+ };
32
+ export const findFireRatedDoors = {
33
+ name: 'find_fire_rated_doors',
34
+ description: 'Find doors that are missing or under-spec on fire rating, and prepare BCF topics.',
35
+ arguments: [
36
+ { name: 'minimum_rating', description: 'Minimum required rating (e.g. EI30).', required: false },
37
+ ],
38
+ render(args) {
39
+ const minimum = args.minimum_rating ?? 'EI30';
40
+ return {
41
+ description: `Find doors with FireRating below ${minimum} or missing`,
42
+ messages: [
43
+ userMessage([
44
+ `Use ifc-lite-mcp tools to:`,
45
+ `1. \`query_entities\` for IfcDoor with property "Pset_DoorCommon.FireRating" missing OR not equal to "${minimum}".`,
46
+ `2. For each non-compliant door, call \`bcf_topic_create\` titled "Fire rating below ${minimum} on <DoorName>" with the GlobalId in the description.`,
47
+ `3. Attach a viewpoint with the door selected via \`bcf_viewpoint_create\`.`,
48
+ `4. Report a summary of how many doors fail and the top 5 by name.`,
49
+ `5. Offer to export the BCF via \`bcf_export\` to ./fire-rating-issues.bcfzip.`,
50
+ ].join('\n')),
51
+ ],
52
+ };
53
+ },
54
+ };
55
+ export const generateBcfFromIds = {
56
+ name: 'generate_bcf_from_ids',
57
+ description: 'Run an IDS validation and create a BCF topic per failed entity.',
58
+ arguments: [
59
+ { name: 'ids_path', description: 'Path to .ids file.', required: true },
60
+ ],
61
+ render(args) {
62
+ return {
63
+ description: 'IDS → BCF',
64
+ messages: [
65
+ userMessage([
66
+ 'Validate the model against the IDS rule set, then create one BCF topic per failed entity.',
67
+ '',
68
+ `1. Call \`ids_validate\` with ids_path="${args.ids_path}".`,
69
+ `2. For each failure with severity error, call \`bcf_topic_create\` (title=requirement name, description=failure reason).`,
70
+ `3. Attach the failing entity GlobalId(s) via \`bcf_viewpoint_create\`.`,
71
+ `4. End with \`bcf_export\` to ./ids-failures.bcfzip and report a summary table grouped by specification name.`,
72
+ ].join('\n')),
73
+ ],
74
+ };
75
+ },
76
+ };
77
+ export const compareVersions = {
78
+ name: 'compare_versions',
79
+ description: 'Diff two loaded models and summarize material/quantity changes by storey.',
80
+ arguments: [
81
+ { name: 'a', description: 'Base model id.', required: true },
82
+ { name: 'b', description: 'Head model id.', required: true },
83
+ ],
84
+ render(args) {
85
+ return {
86
+ description: `Diff ${args.a} vs ${args.b}`,
87
+ messages: [
88
+ userMessage([
89
+ `Use \`model_diff\` to compare \`${args.a}\` and \`${args.b}\` (by_entity=true), then \`quantity_diff\` for IfcWall.Volume and IfcSlab.Area grouped by storey.`,
90
+ `Output a markdown table per storey, flagging any group with > 10 % delta. Conclude with a one-line risk summary.`,
91
+ ].join('\n')),
92
+ ],
93
+ };
94
+ },
95
+ };
96
+ export const spaceProgramCheck = {
97
+ name: 'space_program_check',
98
+ description: 'Compare IfcSpace areas to a target program, list deviations.',
99
+ arguments: [{ name: 'program_csv', description: 'Path to program CSV (Name,TargetArea_m2).', required: true }],
100
+ render(args) {
101
+ return {
102
+ description: 'Space program check',
103
+ messages: [
104
+ userMessage([
105
+ `Read ${args.program_csv}, then for each row find IfcSpace entities by Name (case-insensitive) using \`query_entities\`.`,
106
+ `Compute total NetFloorArea via \`geometry_area\` and compare to TargetArea_m2.`,
107
+ `Output: name, target, actual, delta_m2, delta_pct, sorted by abs(delta_pct) desc. Flag rows where |delta_pct| > 5 %.`,
108
+ ].join('\n')),
109
+ ],
110
+ };
111
+ },
112
+ };
113
+ export const clashReview = {
114
+ name: 'clash_review',
115
+ description: 'Run clash_check, group by trade, prioritize by severity.',
116
+ render() {
117
+ return {
118
+ description: 'Clash review',
119
+ messages: [
120
+ userMessage('Run `clash_check` on the model. Group results by IFC type pair (e.g. IfcWall × IfcDuct) and produce a top-20 priority list for review.'),
121
+ ],
122
+ };
123
+ },
124
+ };
125
+ export const propQualityPass = {
126
+ name: 'prop_quality_pass',
127
+ description: 'Find entities with missing required properties and suggest values from bSDD.',
128
+ arguments: [{ name: 'type', description: 'IFC type to focus on (default: IfcWall).', required: false }],
129
+ render(args) {
130
+ const type = args.type ?? 'IfcWall';
131
+ return {
132
+ description: 'Property quality pass',
133
+ messages: [
134
+ userMessage([
135
+ `For all ${type} entities, list every property that is required by bSDD but missing in the model.`,
136
+ `1. \`bsdd_property_sets\` for ${type}.`,
137
+ `2. For each pset/property pair flagged "isIfcStandard", call \`properties_unique\` to see how often it's set.`,
138
+ `3. Summarize coverage % and the worst offending pset/property combo.`,
139
+ ].join('\n')),
140
+ ],
141
+ };
142
+ },
143
+ };
144
+ export const migrateToIfcx = {
145
+ name: 'migrate_to_ifcx',
146
+ description: 'Walk through migrating a model to IFC5/IFCX and flag attributes that don\'t translate cleanly.',
147
+ render() {
148
+ return {
149
+ description: 'Migrate to IFCX',
150
+ messages: [
151
+ userMessage([
152
+ 'Plan a migration of the active model to IFC5/IFCX:',
153
+ ' • use `schema_describe` to enumerate the entity types in use,',
154
+ ' • flag deprecated attributes,',
155
+ ' • call `export_ifcx` for a dry run and list any UNSUPPORTED_OPERATION codes,',
156
+ ' • produce a migration checklist as bullet points.',
157
+ ].join('\n')),
158
+ ],
159
+ };
160
+ },
161
+ };
162
+ export const visualAudit = {
163
+ name: 'visual_audit',
164
+ description: 'Open the 3D viewer, run model_audit, and paint problem entities so the user can see them at a glance.',
165
+ arguments: [{ name: 'model_id', required: false }],
166
+ render(args) {
167
+ return {
168
+ description: 'Visual model audit',
169
+ messages: [
170
+ userMessage([
171
+ 'Workflow:',
172
+ `1. \`viewer_ask\` (reason: "to highlight audit issues"). Wait for the user to confirm before opening.`,
173
+ `2. \`viewer_open\`${args.model_id ? ` with model_id="${args.model_id}"` : ''}. Tell the user the URL.`,
174
+ `3. \`model_audit\`. For each ERROR, find the entities with \`query_entities\` and \`viewer_colorize\` them red. For warnings, orange.`,
175
+ `4. \`viewer_fly_to\` the worst issue so it's framed when the user opens the browser.`,
176
+ `5. End with: "Pick any element in the viewer and I'll explain it." Then \`viewer_wait_for_selection\` and explain via \`get_entity\`.`,
177
+ ].join('\n')),
178
+ ],
179
+ };
180
+ },
181
+ };
182
+ export const interactivePropertyInspect = {
183
+ name: 'interactive_property_inspect',
184
+ description: 'Open the viewer, wait for the user to click an entity, then explain everything we know about it.',
185
+ arguments: [{ name: 'model_id', required: false }],
186
+ render(args) {
187
+ return {
188
+ description: 'Inspect what the user picks',
189
+ messages: [
190
+ userMessage([
191
+ `1. Confirm with \`viewer_ask\` (reason: "so you can pick the element you want me to inspect").`,
192
+ `2. \`viewer_open\`${args.model_id ? ` with model_id="${args.model_id}"` : ''}.`,
193
+ `3. \`viewer_wait_for_selection\` (timeout 120 s).`,
194
+ `4. Once a pick lands, run \`get_entity\` with include=["attributes","properties","quantities","classifications","materials","relationships"].`,
195
+ `5. Summarize for the user: type, GlobalId, name, key properties, materials, parent storey. Offer follow-ups (similar elements, BCF topic, bSDD lookup).`,
196
+ ].join('\n')),
197
+ ],
198
+ };
199
+ },
200
+ };
201
+ export const visualizeQuery = {
202
+ name: 'visualize_query',
203
+ description: 'Run a query, then color-code matching entities so the user can see them.',
204
+ arguments: [
205
+ { name: 'type', required: true },
206
+ { name: 'pset', required: false },
207
+ { name: 'property', required: false },
208
+ ],
209
+ render(args) {
210
+ return {
211
+ description: `Visualize ${args.type}`,
212
+ messages: [
213
+ userMessage([
214
+ `1. \`viewer_ask\` if not already open.`,
215
+ `2. \`viewer_open\` if confirmed.`,
216
+ args.pset && args.property
217
+ ? `3. \`viewer_color_by_property\` with type="${args.type}", pset="${args.pset}", property="${args.property}". Share the legend.`
218
+ : `3. \`viewer_isolate\` with type="${args.type}". Tell the user how many were highlighted.`,
219
+ `4. \`viewer_fly_to\` the result set.`,
220
+ ].join('\n')),
221
+ ],
222
+ };
223
+ },
224
+ };
225
+ export const allPrompts = [
226
+ auditModel,
227
+ findFireRatedDoors,
228
+ generateBcfFromIds,
229
+ compareVersions,
230
+ spaceProgramCheck,
231
+ clashReview,
232
+ propQualityPass,
233
+ migrateToIfcx,
234
+ visualAudit,
235
+ interactivePropertyInspect,
236
+ visualizeQuery,
237
+ ];
238
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAY/D,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,EAAE,IAAI,EAAE,MAAe,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,EAAE,CAAC;AAC7E,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,EAAE,IAAI,EAAE,QAAiB,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,EAAE,CAAC;AAC/E,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAW;IAChC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,kFAAkF;IAC/F,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,6BAA6B,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC9F,MAAM,CAAC,IAAI;QACT,OAAO;YACL,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE;gBACR,aAAa,CAAC,qDAAqD,CAAC;gBACpE,WAAW,CACT;oBACE,uCAAuC;oBACvC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE;oBACrD,8DAA8D;oBAC9D,uEAAuE;oBACvE,8BAA8B;oBAC9B,+FAA+F;oBAC/F,yGAAyG;iBAC1G,CAAC,IAAI,CAAC,EAAE,CAAC,CACX;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF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C,IAAI,CAAC,IAAI,6CAA6C;oBAC9F,sCAAsC;iBACvC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACd;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAa;IAClC,UAAU;IACV,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,iBAAiB;IACjB,WAAW;IACX,eAAe;IACf,aAAa;IACb,WAAW;IACX,0BAA0B;IAC1B,cAAc;CACf,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { GetPromptResult, PromptArgument, PromptDefinition } from '../protocol/index.js';
2
+ import type { ToolContext } from '../context.js';
3
+ export interface Prompt {
4
+ name: string;
5
+ description: string;
6
+ arguments?: PromptArgument[];
7
+ /** Build the message list. Receives validated string args. */
8
+ render(args: Record<string, string>, ctx: ToolContext): Promise<GetPromptResult> | GetPromptResult;
9
+ }
10
+ export declare class PromptRegistry {
11
+ private prompts;
12
+ register(prompt: Prompt): void;
13
+ registerAll(prompts: Prompt[]): void;
14
+ get(name: string): Prompt | null;
15
+ list(): PromptDefinition[];
16
+ }
17
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,8DAA8D;IAC9D,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;CACpG;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAA6B;IAE5C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAO9B,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAIpC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIhC,IAAI,IAAI,gBAAgB,EAAE;CAO3B"}
@@ -0,0 +1,27 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ export class PromptRegistry {
5
+ prompts = new Map();
6
+ register(prompt) {
7
+ if (this.prompts.has(prompt.name)) {
8
+ throw new Error(`Duplicate prompt registration: ${prompt.name}`);
9
+ }
10
+ this.prompts.set(prompt.name, prompt);
11
+ }
12
+ registerAll(prompts) {
13
+ for (const p of prompts)
14
+ this.register(p);
15
+ }
16
+ get(name) {
17
+ return this.prompts.get(name) ?? null;
18
+ }
19
+ list() {
20
+ return Array.from(this.prompts.values()).map((p) => ({
21
+ name: p.name,
22
+ description: p.description,
23
+ arguments: p.arguments,
24
+ }));
25
+ }
26
+ }
27
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAa/D,MAAM,OAAO,cAAc;IACjB,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE5C,QAAQ,CAAC,MAAc;QACrB,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,kCAAkC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,WAAW,CAAC,OAAiB;QAC3B,KAAK,MAAM,CAAC,IAAI,OAAO;YAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IACxC,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnD,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,SAAS,EAAE,CAAC,CAAC,SAAS;SACvB,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export { isJsonRpcRequest, isJsonRpcNotification, isJsonRpcResponse, successResponse, errorResponse, notification, parseMessage, } from './jsonrpc.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ export * from './types.js';
5
+ export { isJsonRpcRequest, isJsonRpcNotification, isJsonRpcResponse, successResponse, errorResponse, notification, parseMessage, } from './jsonrpc.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,cAAc,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * JSON-RPC 2.0 helpers used by every MCP transport.
3
+ */
4
+ import { JsonRpcId, JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse } from './types.js';
5
+ export declare function isJsonRpcRequest(msg: unknown): msg is JsonRpcRequest;
6
+ export declare function isJsonRpcNotification(msg: unknown): msg is JsonRpcNotification;
7
+ export declare function isJsonRpcResponse(msg: unknown): msg is JsonRpcResponse;
8
+ export declare function successResponse<R>(id: JsonRpcId, result: R): JsonRpcSuccessResponse<R>;
9
+ export declare function errorResponse(id: JsonRpcId | null, code: number, message: string, data?: unknown): JsonRpcErrorResponse;
10
+ export declare function notification<P>(method: string, params?: P): JsonRpcNotification<P>;
11
+ export declare function parseMessage(text: string): JsonRpcMessage | null;
12
+ //# sourceMappingURL=jsonrpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/protocol/jsonrpc.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAEL,SAAS,EAET,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAMpE;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,mBAAmB,CAM9E;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,eAAe,CAKtE;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAEtF;AAED,wBAAgB,aAAa,CAC3B,EAAE,EAAE,SAAS,GAAG,IAAI,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,OAAO,GACb,oBAAoB,CAItB;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAIlF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAWhE"}
@@ -0,0 +1,62 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ /**
5
+ * JSON-RPC 2.0 helpers used by every MCP transport.
6
+ */
7
+ import { JSONRPC_VERSION, } from './types.js';
8
+ export function isJsonRpcRequest(msg) {
9
+ if (!msg || typeof msg !== 'object')
10
+ return false;
11
+ const m = msg;
12
+ return m.jsonrpc === JSONRPC_VERSION
13
+ && typeof m.method === 'string'
14
+ && m.id !== undefined;
15
+ }
16
+ export function isJsonRpcNotification(msg) {
17
+ if (!msg || typeof msg !== 'object')
18
+ return false;
19
+ const m = msg;
20
+ return m.jsonrpc === JSONRPC_VERSION
21
+ && typeof m.method === 'string'
22
+ && m.id === undefined;
23
+ }
24
+ export function isJsonRpcResponse(msg) {
25
+ if (!msg || typeof msg !== 'object')
26
+ return false;
27
+ const m = msg;
28
+ if (m.jsonrpc !== JSONRPC_VERSION)
29
+ return false;
30
+ return 'result' in m || 'error' in m;
31
+ }
32
+ export function successResponse(id, result) {
33
+ return { jsonrpc: JSONRPC_VERSION, id, result };
34
+ }
35
+ export function errorResponse(id, code, message, data) {
36
+ const err = { code, message };
37
+ if (data !== undefined)
38
+ err.data = data;
39
+ return { jsonrpc: JSONRPC_VERSION, id, error: err };
40
+ }
41
+ export function notification(method, params) {
42
+ const note = { jsonrpc: JSONRPC_VERSION, method };
43
+ if (params !== undefined)
44
+ note.params = params;
45
+ return note;
46
+ }
47
+ export function parseMessage(text) {
48
+ try {
49
+ const parsed = JSON.parse(text);
50
+ if (!parsed || typeof parsed !== 'object')
51
+ return null;
52
+ if (parsed.jsonrpc !== JSONRPC_VERSION)
53
+ return null;
54
+ return parsed;
55
+ }
56
+ catch {
57
+ // Caller decides how to surface parse errors — most transports send
58
+ // back a JSON-RPC ParseError response with id=null.
59
+ return null;
60
+ }
61
+ }
62
+ //# sourceMappingURL=jsonrpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../../src/protocol/jsonrpc.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;GAEG;AAEH,OAAO,EACL,eAAe,GAShB,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,CAAC,GAAG,GAAqB,CAAC;IAChC,OAAO,CAAC,CAAC,OAAO,KAAK,eAAe;WAC/B,OAAQ,CAAoB,CAAC,MAAM,KAAK,QAAQ;WAC/C,CAAoB,CAAC,EAAE,KAAK,SAAS,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAChD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,CAAC,GAAG,GAAqB,CAAC;IAChC,OAAO,CAAC,CAAC,OAAO,KAAK,eAAe;WAC/B,OAAQ,CAAyB,CAAC,MAAM,KAAK,QAAQ;WACpD,CAAoB,CAAC,E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