@vinkius-core/mcp-fusion 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/cli/fusion.d.ts +101 -0
  2. package/dist/cli/fusion.d.ts.map +1 -0
  3. package/dist/cli/fusion.js +333 -0
  4. package/dist/cli/fusion.js.map +1 -0
  5. package/dist/client/FusionClient.d.ts +122 -1
  6. package/dist/client/FusionClient.d.ts.map +1 -1
  7. package/dist/client/FusionClient.js +173 -11
  8. package/dist/client/FusionClient.js.map +1 -1
  9. package/dist/client/index.d.ts +2 -2
  10. package/dist/client/index.d.ts.map +1 -1
  11. package/dist/client/index.js +1 -1
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/core/StandardSchema.d.ts +178 -0
  14. package/dist/core/StandardSchema.d.ts.map +1 -0
  15. package/dist/core/StandardSchema.js +166 -0
  16. package/dist/core/StandardSchema.js.map +1 -0
  17. package/dist/core/createGroup.d.ts +140 -0
  18. package/dist/core/createGroup.d.ts.map +1 -0
  19. package/dist/core/createGroup.js +133 -0
  20. package/dist/core/createGroup.js.map +1 -0
  21. package/dist/core/execution/ExecutionPipeline.d.ts.map +1 -1
  22. package/dist/core/execution/ExecutionPipeline.js +6 -2
  23. package/dist/core/execution/ExecutionPipeline.js.map +1 -1
  24. package/dist/core/index.d.ts +7 -1
  25. package/dist/core/index.d.ts.map +1 -1
  26. package/dist/core/index.js +6 -0
  27. package/dist/core/index.js.map +1 -1
  28. package/dist/core/initFusion.d.ts +201 -0
  29. package/dist/core/initFusion.d.ts.map +1 -0
  30. package/dist/core/initFusion.js +134 -0
  31. package/dist/core/initFusion.js.map +1 -0
  32. package/dist/core/response.d.ts +49 -2
  33. package/dist/core/response.d.ts.map +1 -1
  34. package/dist/core/response.js +27 -5
  35. package/dist/core/response.js.map +1 -1
  36. package/dist/index.d.ts +57 -9
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +30 -4
  39. package/dist/index.js.map +1 -1
  40. package/dist/introspection/BehaviorDigest.d.ts +112 -0
  41. package/dist/introspection/BehaviorDigest.d.ts.map +1 -0
  42. package/dist/introspection/BehaviorDigest.js +146 -0
  43. package/dist/introspection/BehaviorDigest.js.map +1 -0
  44. package/dist/introspection/CapabilityLockfile.d.ts +259 -0
  45. package/dist/introspection/CapabilityLockfile.d.ts.map +1 -0
  46. package/dist/introspection/CapabilityLockfile.js +391 -0
  47. package/dist/introspection/CapabilityLockfile.js.map +1 -0
  48. package/dist/introspection/ContractAwareSelfHealing.d.ts +90 -0
  49. package/dist/introspection/ContractAwareSelfHealing.d.ts.map +1 -0
  50. package/dist/introspection/ContractAwareSelfHealing.js +132 -0
  51. package/dist/introspection/ContractAwareSelfHealing.js.map +1 -0
  52. package/dist/introspection/ContractDiff.d.ts +91 -0
  53. package/dist/introspection/ContractDiff.d.ts.map +1 -0
  54. package/dist/introspection/ContractDiff.js +466 -0
  55. package/dist/introspection/ContractDiff.js.map +1 -0
  56. package/dist/introspection/CryptoAttestation.d.ts +143 -0
  57. package/dist/introspection/CryptoAttestation.d.ts.map +1 -0
  58. package/dist/introspection/CryptoAttestation.js +194 -0
  59. package/dist/introspection/CryptoAttestation.js.map +1 -0
  60. package/dist/introspection/EntitlementScanner.d.ts +124 -0
  61. package/dist/introspection/EntitlementScanner.d.ts.map +1 -0
  62. package/dist/introspection/EntitlementScanner.js +244 -0
  63. package/dist/introspection/EntitlementScanner.js.map +1 -0
  64. package/dist/introspection/GovernanceObserver.d.ts +88 -0
  65. package/dist/introspection/GovernanceObserver.d.ts.map +1 -0
  66. package/dist/introspection/GovernanceObserver.js +132 -0
  67. package/dist/introspection/GovernanceObserver.js.map +1 -0
  68. package/dist/introspection/SemanticProbe.d.ts +207 -0
  69. package/dist/introspection/SemanticProbe.d.ts.map +1 -0
  70. package/dist/introspection/SemanticProbe.js +255 -0
  71. package/dist/introspection/SemanticProbe.js.map +1 -0
  72. package/dist/introspection/TokenEconomics.d.ts +210 -0
  73. package/dist/introspection/TokenEconomics.d.ts.map +1 -0
  74. package/dist/introspection/TokenEconomics.js +286 -0
  75. package/dist/introspection/TokenEconomics.js.map +1 -0
  76. package/dist/introspection/ToolContract.d.ts +159 -0
  77. package/dist/introspection/ToolContract.d.ts.map +1 -0
  78. package/dist/introspection/ToolContract.js +191 -0
  79. package/dist/introspection/ToolContract.js.map +1 -0
  80. package/dist/introspection/canonicalize.d.ts +20 -0
  81. package/dist/introspection/canonicalize.d.ts.map +1 -0
  82. package/dist/introspection/canonicalize.js +51 -0
  83. package/dist/introspection/canonicalize.js.map +1 -0
  84. package/dist/introspection/index.d.ts +20 -0
  85. package/dist/introspection/index.d.ts.map +1 -1
  86. package/dist/introspection/index.js +20 -0
  87. package/dist/introspection/index.js.map +1 -1
  88. package/dist/observability/DebugObserver.d.ts +26 -1
  89. package/dist/observability/DebugObserver.d.ts.map +1 -1
  90. package/dist/observability/DebugObserver.js +8 -1
  91. package/dist/observability/DebugObserver.js.map +1 -1
  92. package/dist/observability/index.d.ts +1 -1
  93. package/dist/observability/index.d.ts.map +1 -1
  94. package/dist/observability/index.js.map +1 -1
  95. package/dist/presenter/ZodDescriptionExtractor.d.ts +54 -0
  96. package/dist/presenter/ZodDescriptionExtractor.d.ts.map +1 -0
  97. package/dist/presenter/ZodDescriptionExtractor.js +131 -0
  98. package/dist/presenter/ZodDescriptionExtractor.js.map +1 -0
  99. package/dist/presenter/definePresenter.d.ts +172 -0
  100. package/dist/presenter/definePresenter.d.ts.map +1 -0
  101. package/dist/presenter/definePresenter.js +96 -0
  102. package/dist/presenter/definePresenter.js.map +1 -0
  103. package/dist/presenter/index.d.ts +3 -0
  104. package/dist/presenter/index.d.ts.map +1 -1
  105. package/dist/presenter/index.js +4 -0
  106. package/dist/presenter/index.js.map +1 -1
  107. package/dist/server/DevServer.d.ts +96 -0
  108. package/dist/server/DevServer.d.ts.map +1 -0
  109. package/dist/server/DevServer.js +187 -0
  110. package/dist/server/DevServer.js.map +1 -0
  111. package/dist/server/ServerAttachment.d.ts +41 -0
  112. package/dist/server/ServerAttachment.d.ts.map +1 -1
  113. package/dist/server/ServerAttachment.js +25 -1
  114. package/dist/server/ServerAttachment.js.map +1 -1
  115. package/dist/server/autoDiscover.d.ts +63 -0
  116. package/dist/server/autoDiscover.d.ts.map +1 -0
  117. package/dist/server/autoDiscover.js +157 -0
  118. package/dist/server/autoDiscover.js.map +1 -0
  119. package/dist/server/index.d.ts +4 -0
  120. package/dist/server/index.d.ts.map +1 -1
  121. package/dist/server/index.js +4 -0
  122. package/dist/server/index.js.map +1 -1
  123. package/dist/state-sync/PolicyValidator.d.ts +36 -0
  124. package/dist/state-sync/PolicyValidator.d.ts.map +1 -1
  125. package/dist/state-sync/PolicyValidator.js +35 -0
  126. package/dist/state-sync/PolicyValidator.js.map +1 -1
  127. package/dist/state-sync/ResponseDecorator.d.ts.map +1 -1
  128. package/dist/state-sync/ResponseDecorator.js +2 -1
  129. package/dist/state-sync/ResponseDecorator.js.map +1 -1
  130. package/dist/state-sync/StateSyncLayer.d.ts +5 -4
  131. package/dist/state-sync/StateSyncLayer.d.ts.map +1 -1
  132. package/dist/state-sync/StateSyncLayer.js +35 -4
  133. package/dist/state-sync/StateSyncLayer.js.map +1 -1
  134. package/dist/state-sync/index.d.ts +3 -1
  135. package/dist/state-sync/index.d.ts.map +1 -1
  136. package/dist/state-sync/index.js +1 -0
  137. package/dist/state-sync/index.js.map +1 -1
  138. package/dist/state-sync/types.d.ts +62 -0
  139. package/dist/state-sync/types.d.ts.map +1 -1
  140. package/package.json +45 -1
@@ -0,0 +1,146 @@
1
+ import { sha256, canonicalize } from './canonicalize.js';
2
+ // ============================================================================
3
+ // Digest Computation
4
+ // ============================================================================
5
+ /**
6
+ * Compute the behavioral digest for a single tool contract.
7
+ *
8
+ * The digest is deterministic: same contract → same digest.
9
+ * It uses canonical JSON serialization (sorted keys) to ensure
10
+ * platform-independent consistency.
11
+ *
12
+ * @param contract - The materialized tool contract
13
+ * @returns Content-addressed digest with per-section components
14
+ */
15
+ export function computeDigest(contract) {
16
+ const surfaceHash = hashSection({
17
+ name: contract.surface.name,
18
+ description: contract.surface.description,
19
+ tags: [...contract.surface.tags].sort(),
20
+ inputSchemaDigest: contract.surface.inputSchemaDigest,
21
+ actions: sortedActions(contract),
22
+ });
23
+ const behaviorHash = hashSection({
24
+ egressSchemaDigest: contract.behavior.egressSchemaDigest,
25
+ systemRulesFingerprint: contract.behavior.systemRulesFingerprint,
26
+ cognitiveGuardrails: contract.behavior.cognitiveGuardrails,
27
+ middlewareChain: contract.behavior.middlewareChain,
28
+ stateSyncFingerprint: contract.behavior.stateSyncFingerprint,
29
+ concurrencyFingerprint: contract.behavior.concurrencyFingerprint,
30
+ affordanceTopology: [...contract.behavior.affordanceTopology],
31
+ embeddedPresenters: [...contract.behavior.embeddedPresenters],
32
+ });
33
+ const tokenEconomicsHash = hashSection({
34
+ schemaFieldCount: contract.tokenEconomics.schemaFieldCount,
35
+ unboundedCollection: contract.tokenEconomics.unboundedCollection,
36
+ baseOverheadTokens: contract.tokenEconomics.baseOverheadTokens,
37
+ inflationRisk: contract.tokenEconomics.inflationRisk,
38
+ });
39
+ const entitlementsHash = hashSection({
40
+ filesystem: contract.entitlements.filesystem,
41
+ network: contract.entitlements.network,
42
+ subprocess: contract.entitlements.subprocess,
43
+ crypto: contract.entitlements.crypto,
44
+ raw: [...contract.entitlements.raw].sort(),
45
+ });
46
+ // Composite digest over all components
47
+ const compositeInput = [surfaceHash, behaviorHash, tokenEconomicsHash, entitlementsHash].join(':');
48
+ const digest = sha256(compositeInput);
49
+ return {
50
+ digest,
51
+ components: {
52
+ surface: surfaceHash,
53
+ behavior: behaviorHash,
54
+ tokenEconomics: tokenEconomicsHash,
55
+ entitlements: entitlementsHash,
56
+ },
57
+ computedAt: new Date().toISOString(),
58
+ toolName: contract.surface.name,
59
+ };
60
+ }
61
+ /**
62
+ * Compute a server-level digest covering all tools.
63
+ *
64
+ * The server digest is the SHA-256 over all per-tool digests,
65
+ * sorted by tool name for determinism.
66
+ *
67
+ * @param contracts - Record of tool name → contract
68
+ * @returns Server-level content-addressed digest
69
+ */
70
+ export function computeServerDigest(contracts) {
71
+ const tools = {};
72
+ const sortedNames = Object.keys(contracts).sort();
73
+ const perToolDigests = [];
74
+ for (const name of sortedNames) {
75
+ const result = computeDigest(contracts[name]);
76
+ tools[name] = result;
77
+ perToolDigests.push(`${name}:${result.digest}`);
78
+ }
79
+ const digest = sha256(perToolDigests.join('\n'));
80
+ return {
81
+ digest,
82
+ tools,
83
+ computedAt: new Date().toISOString(),
84
+ };
85
+ }
86
+ /**
87
+ * Compare two server digests and return which tools changed.
88
+ *
89
+ * @param before - Previous server digest
90
+ * @param after - Current server digest
91
+ * @returns Object with added, removed, and changed tool names
92
+ */
93
+ export function compareServerDigests(before, after) {
94
+ const beforeNames = new Set(Object.keys(before.tools));
95
+ const afterNames = new Set(Object.keys(after.tools));
96
+ const added = [];
97
+ const removed = [];
98
+ const changed = [];
99
+ const unchanged = [];
100
+ for (const name of afterNames) {
101
+ if (!beforeNames.has(name)) {
102
+ added.push(name);
103
+ }
104
+ else if (before.tools[name].digest !== after.tools[name].digest) {
105
+ changed.push(name);
106
+ }
107
+ else {
108
+ unchanged.push(name);
109
+ }
110
+ }
111
+ for (const name of beforeNames) {
112
+ if (!afterNames.has(name)) {
113
+ removed.push(name);
114
+ }
115
+ }
116
+ return {
117
+ serverDigestChanged: before.digest !== after.digest,
118
+ added,
119
+ removed,
120
+ changed,
121
+ unchanged,
122
+ };
123
+ }
124
+ // ============================================================================
125
+ // Internals
126
+ // ============================================================================
127
+ /**
128
+ * Sort actions by key for deterministic hashing.
129
+ * @internal
130
+ */
131
+ function sortedActions(contract) {
132
+ return Object.keys(contract.surface.actions)
133
+ .sort()
134
+ .map(key => ({
135
+ key,
136
+ ...contract.surface.actions[key],
137
+ }));
138
+ }
139
+ /**
140
+ * Hash a section object using canonical JSON serialization.
141
+ * @internal
142
+ */
143
+ function hashSection(obj) {
144
+ return sha256(canonicalize(obj));
145
+ }
146
+ //# sourceMappingURL=BehaviorDigest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BehaviorDigest.js","sourceRoot":"","sources":["../../src/introspection/BehaviorDigest.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAwDzD,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,QAAsB;IAChD,MAAM,WAAW,GAAG,WAAW,CAAC;QAC5B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI;QAC3B,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW;QACzC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;QACvC,iBAAiB,EAAE,QAAQ,CAAC,OAAO,CAAC,iBAAiB;QACrD,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC;KACnC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,WAAW,CAAC;QAC7B,kBAAkB,EAAE,QAAQ,CAAC,QAAQ,CAAC,kBAAkB;QACxD,sBAAsB,EAAE,QAAQ,CAAC,QAAQ,CAAC,sBAAsB;QAChE,mBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,mBAAmB;QAC1D,eAAe,EAAE,QAAQ,CAAC,QAAQ,CAAC,eAAe;QAClD,oBAAoB,EAAE,QAAQ,CAAC,QAAQ,CAAC,oBAAoB;QAC5D,sBAAsB,EAAE,QAAQ,CAAC,QAAQ,CAAC,sBAAsB;QAChE,kBAAkB,EAAE,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC7D,kBAAkB,EAAE,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC;KAChE,CAAC,CAAC;IAEH,MAA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CAAC;YAClE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACL,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAED,OAAO;QACH,mBAAmB,EAAE,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QACnD,KAAK;QACL,OAAO;QACP,OAAO;QACP,SAAS;KACZ,CAAC;AACN,CAAC;AAkBD,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;GAGG;AACH,SAAS,aAAa,CAAC,QAAsB;IACzC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;SACvC,IAAI,EAAE;SACN,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACT,GAAG;QACH,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACnC,CAAC,CAAC,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,GAAY;IAC7B,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,259 @@
1
+ import type { ToolContract } from './ToolContract.js';
2
+ /** Current lockfile format version. */
3
+ declare const LOCKFILE_VERSION: 1;
4
+ /** Default lockfile name. */
5
+ export declare const LOCKFILE_NAME: "mcp-fusion.lock";
6
+ /**
7
+ * Root structure of `mcp-fusion.lock`.
8
+ *
9
+ * Designed for human reviewability in pull request diffs.
10
+ * Keys are sorted, values are deterministic.
11
+ */
12
+ export interface CapabilityLockfile {
13
+ /** Format version for forward-compatible parsing */
14
+ readonly lockfileVersion: typeof LOCKFILE_VERSION;
15
+ /** MCP server name */
16
+ readonly serverName: string;
17
+ /** MCP Fusion framework version */
18
+ readonly fusionVersion: string;
19
+ /** ISO-8601 generation timestamp */
20
+ readonly generatedAt: string;
21
+ /** SHA-256 over all tool digests — the server's behavioral identity */
22
+ readonly integrityDigest: string;
23
+ /** Per-capability lockfile entries */
24
+ readonly capabilities: LockfileCapabilities;
25
+ }
26
+ /**
27
+ * Capability sections in the lockfile.
28
+ *
29
+ * Currently supports `tools` and `prompts`. Future sections may
30
+ * include `resources` and `subscriptions`.
31
+ */
32
+ export interface LockfileCapabilities {
33
+ /** Per-tool behavioral snapshots, sorted by tool name */
34
+ readonly tools: Readonly<Record<string, LockfileTool>>;
35
+ /** Per-prompt declarative snapshots, sorted by prompt name */
36
+ readonly prompts?: Readonly<Record<string, LockfilePrompt>>;
37
+ }
38
+ /**
39
+ * Behavioral snapshot for a single tool.
40
+ *
41
+ * Every field is derived from the `ToolContract` — no manual
42
+ * annotation required. The snapshot captures everything an LLM
43
+ * relies on to behave correctly with this tool.
44
+ */
45
+ export interface LockfileTool {
46
+ /** SHA-256 integrity digest for this tool's behavioral contract */
47
+ readonly integrityDigest: string;
48
+ /** Declarative surface visible via MCP `tools/list` */
49
+ readonly surface: LockfileToolSurface;
50
+ /** Behavioral contract internals */
51
+ readonly behavior: LockfileToolBehavior;
52
+ /** Token economics profile */
53
+ readonly tokenEconomics: LockfileTokenEconomics;
54
+ /** Handler entitlements (I/O capabilities) */
55
+ readonly entitlements: LockfileEntitlements;
56
+ }
57
+ /** Surface section of a lockfile tool entry. */
58
+ export interface LockfileToolSurface {
59
+ /** Tool description */
60
+ readonly description: string | null;
61
+ /** Sorted action keys */
62
+ readonly actions: readonly string[];
63
+ /** SHA-256 of the canonical input schema */
64
+ readonly inputSchemaDigest: string;
65
+ /** Sorted tags */
66
+ readonly tags: readonly string[];
67
+ }
68
+ /** Behavior section of a lockfile tool entry. */
69
+ export interface LockfileToolBehavior {
70
+ /** Presenter egress schema digest (null if no Presenter) */
71
+ readonly egressSchemaDigest: string | null;
72
+ /** System rules fingerprint */
73
+ readonly systemRulesFingerprint: string;
74
+ /** Actions marked as destructive */
75
+ readonly destructiveActions: readonly string[];
76
+ /** Actions marked as read-only */
77
+ readonly readOnlyActions: readonly string[];
78
+ /** Named middleware chain */
79
+ readonly middlewareChain: readonly string[];
80
+ /** Affordance topology — suggested next-action tool names */
81
+ readonly affordanceTopology: readonly string[];
82
+ /** Cognitive guardrails */
83
+ readonly cognitiveGuardrails: {
84
+ readonly agentLimitMax: number | null;
85
+ readonly egressMaxBytes: number | null;
86
+ };
87
+ }
88
+ /** Token economics section of a lockfile tool entry. */
89
+ export interface LockfileTokenEconomics {
90
+ /** Cognitive overload risk classification */
91
+ readonly inflationRisk: string;
92
+ /** Number of fields in the egress schema */
93
+ readonly schemaFieldCount: number;
94
+ /** Whether output collections are unbounded */
95
+ readonly unboundedCollection: boolean;
96
+ }
97
+ /** Entitlements section of a lockfile tool entry. */
98
+ export interface LockfileEntitlements {
99
+ /** Filesystem I/O */
100
+ readonly filesystem: boolean;
101
+ /** Network I/O */
102
+ readonly network: boolean;
103
+ /** Subprocess execution */
104
+ readonly subprocess: boolean;
105
+ /** Cryptographic operations */
106
+ readonly crypto: boolean;
107
+ }
108
+ /**
109
+ * Duck-typed interface for prompt builders.
110
+ *
111
+ * Decouples the lockfile module from the Prompt Engine implementation.
112
+ * Any object implementing these methods can be snapshotted.
113
+ */
114
+ export interface PromptBuilderLike {
115
+ getName(): string;
116
+ getDescription(): string | undefined;
117
+ getTags(): string[];
118
+ hasMiddleware(): boolean;
119
+ getHydrationTimeout(): number | undefined;
120
+ buildPromptDefinition(): {
121
+ name: string;
122
+ title?: string;
123
+ description?: string;
124
+ icons?: {
125
+ light?: string;
126
+ dark?: string;
127
+ };
128
+ arguments?: Array<{
129
+ name: string;
130
+ description?: string;
131
+ required?: boolean;
132
+ }>;
133
+ };
134
+ }
135
+ /**
136
+ * Behavioral snapshot for a single prompt.
137
+ *
138
+ * Captures the declarative surface that an LLM client relies on
139
+ * to offer the correct slash-command palette. Changes to arguments,
140
+ * descriptions, or middleware affect how the LLM invokes the prompt.
141
+ */
142
+ export interface LockfilePrompt {
143
+ /** SHA-256 integrity digest for this prompt's declarative contract */
144
+ readonly integrityDigest: string;
145
+ /** Human-readable description */
146
+ readonly description: string | null;
147
+ /** Display title (MCP BaseMetadata.title) */
148
+ readonly title: string | null;
149
+ /** Sorted capability tags */
150
+ readonly tags: readonly string[];
151
+ /** Argument definitions from the Zod schema */
152
+ readonly arguments: readonly LockfilePromptArgument[];
153
+ /** SHA-256 of canonical arguments JSON */
154
+ readonly argumentsDigest: string;
155
+ /** Whether middleware is attached to this prompt */
156
+ readonly hasMiddleware: boolean;
157
+ /** Hydration timeout in ms, or null if unlimited */
158
+ readonly hydrationTimeout: number | null;
159
+ }
160
+ /** A single prompt argument definition. */
161
+ export interface LockfilePromptArgument {
162
+ /** Argument name */
163
+ readonly name: string;
164
+ /** Human-readable description */
165
+ readonly description: string | null;
166
+ /** Whether this argument is required */
167
+ readonly required: boolean;
168
+ }
169
+ /**
170
+ * Options for lockfile generation beyond tools.
171
+ */
172
+ export interface GenerateLockfileOptions {
173
+ /** Prompt builders to snapshot alongside tools */
174
+ readonly prompts?: ReadonlyArray<PromptBuilderLike>;
175
+ }
176
+ /**
177
+ * Generate a `CapabilityLockfile` from compiled tool contracts
178
+ * and (optionally) prompt builders.
179
+ *
180
+ * This is a **pure function**: given the same contracts and metadata,
181
+ * it always produces the same lockfile (modulo `generatedAt` timestamp).
182
+ *
183
+ * @param serverName - MCP server name
184
+ * @param contracts - Record of tool name → materialized contract
185
+ * @param fusionVersion - MCP Fusion version string
186
+ * @param options - Optional: prompt builders to include
187
+ * @returns A fully materialized lockfile
188
+ */
189
+ export declare function generateLockfile(serverName: string, contracts: Readonly<Record<string, ToolContract>>, fusionVersion: string, options?: GenerateLockfileOptions): CapabilityLockfile;
190
+ /**
191
+ * Serialize a lockfile to a deterministic JSON string.
192
+ *
193
+ * Uses sorted keys and 2-space indentation for git-friendly diffs.
194
+ * The output is canonical — identical lockfiles produce identical strings.
195
+ *
196
+ * @param lockfile - The lockfile to serialize
197
+ * @returns Deterministic JSON string with trailing newline
198
+ */
199
+ export declare function serializeLockfile(lockfile: CapabilityLockfile): string;
200
+ /**
201
+ * Result of a lockfile verification check.
202
+ */
203
+ export interface LockfileCheckResult {
204
+ /** Whether the lockfile matches the current server surface */
205
+ readonly ok: boolean;
206
+ /** Human-readable status message */
207
+ readonly message: string;
208
+ /** Added tools since lockfile was generated */
209
+ readonly added: readonly string[];
210
+ /** Removed tools since lockfile was generated */
211
+ readonly removed: readonly string[];
212
+ /** Tools whose behavioral digest changed */
213
+ readonly changed: readonly string[];
214
+ /** Tools that match the lockfile exactly */
215
+ readonly unchanged: readonly string[];
216
+ /** Added prompts since lockfile was generated */
217
+ readonly addedPrompts: readonly string[];
218
+ /** Removed prompts since lockfile was generated */
219
+ readonly removedPrompts: readonly string[];
220
+ /** Prompts whose declarative digest changed */
221
+ readonly changedPrompts: readonly string[];
222
+ /** Prompts that match the lockfile exactly */
223
+ readonly unchangedPrompts: readonly string[];
224
+ }
225
+ /**
226
+ * Verify that a lockfile matches the current server contracts and prompts.
227
+ *
228
+ * This is the **CI gate**: `fusion lock --check` calls this function
229
+ * and exits non-zero if the lockfile is stale.
230
+ *
231
+ * @param lockfile - Previously generated lockfile (from disk)
232
+ * @param contracts - Current compiled tool contracts (from code)
233
+ * @param options - Optional: prompt builders for prompt verification
234
+ * @returns Check result with per-tool and per-prompt diff details
235
+ */
236
+ export declare function checkLockfile(lockfile: CapabilityLockfile, contracts: Readonly<Record<string, ToolContract>>, options?: GenerateLockfileOptions): LockfileCheckResult;
237
+ /**
238
+ * Parse and validate a lockfile JSON string.
239
+ *
240
+ * @param content - Raw JSON string from `mcp-fusion.lock`
241
+ * @returns Parsed lockfile, or null if invalid
242
+ */
243
+ export declare function parseLockfile(content: string): CapabilityLockfile | null;
244
+ /**
245
+ * Write a lockfile to disk.
246
+ *
247
+ * @param lockfile - The lockfile to persist
248
+ * @param projectRoot - Project root directory
249
+ */
250
+ export declare function writeLockfile(lockfile: CapabilityLockfile, projectRoot: string): Promise<void>;
251
+ /**
252
+ * Read a lockfile from disk.
253
+ *
254
+ * @param projectRoot - Project root directory
255
+ * @returns Parsed lockfile, or null if not found / invalid
256
+ */
257
+ export declare function readLockfile(projectRoot: string): Promise<CapabilityLockfile | null>;
258
+ export {};
259
+ //# sourceMappingURL=CapabilityLockfile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CapabilityLockfile.d.ts","sourceRoot":"","sources":["../../src/introspection/CapabilityLockfile.ts"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAStD,uCAAuC;AACvC,QAAA,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAEpC,6BAA6B;AAC7B,eAAO,MAAM,aAAa,EAAG,iBAA0B,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,eAAe,EAAE,OAAO,gBAAgB,CAAC;IAClD,sBAAsB;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,mCAAmC;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,oCAAoC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,sCAAsC;IACtC,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;CAC/C;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACjC,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACvD,8DAA8D;IAC9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