minutes-mcp 0.30.9 → 0.31.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.
@@ -2,7 +2,8 @@ type ExecFileAsync = (file: string, args: readonly string[], options?: {
2
2
  timeout?: number;
3
3
  env?: NodeJS.ProcessEnv;
4
4
  }) => Promise<unknown>;
5
- export declare const MACOS_SHERPA_ARCHIVE = "minutes-macos-arm64-sherpa.tar.gz";
5
+ export declare const MACOS_SHERPA_ARCHIVE = "minutes-macos-arm64-sherpa-shared.tar.gz";
6
+ export declare const MACOS_LEGACY_SHERPA_ARCHIVE = "minutes-macos-arm64-sherpa.tar.gz";
6
7
  export declare const MACOS_BARE_BINARY = "minutes-macos-arm64";
7
8
  export declare class ReleaseAssetUnavailableError extends Error {
8
9
  readonly assetName: string;
@@ -17,9 +18,10 @@ export declare function findSha256ForAsset(raw: string, assetName: string): stri
17
18
  export declare function computeFileSha256(path: string): Promise<string>;
18
19
  export declare function verifyDownloadedAsset(path: string, expectedSha256: string): Promise<void>;
19
20
  /**
20
- * Extract the two files from the macOS sherpa release archive.
21
+ * Extract the fixed files from the macOS sherpa release archive.
21
22
  *
22
- * The release archive has one fixed directory and two fixed regular files.
23
+ * Both generations use one fixed directory: the CLI and plugin, optionally
24
+ * accompanied by the complete pair of shared libraries. Partial pairs fail.
23
25
  * Keeping this reader deliberately narrow avoids a package dependency and,
24
26
  * more importantly, prevents path traversal, links, devices, or unexpected
25
27
  * files from ever being materialized. The archive itself is SHA-256 verified
@@ -31,6 +33,7 @@ export declare function extractMacSherpaArchive(options: {
31
33
  }): Promise<{
32
34
  binaryPath: string;
33
35
  pluginPath: string;
36
+ libraryPaths: string[];
34
37
  }>;
35
38
  /**
36
39
  * Commit a verified binary/plugin pair. The binary rename is the commit point:
@@ -41,6 +44,8 @@ export declare function extractMacSherpaArchive(options: {
41
44
  export declare function atomicReplaceMacSherpaFiles(options: {
42
45
  stagedBinaryPath: string;
43
46
  stagedPluginPath: string;
47
+ /** Shared libraries the plugin loads from its own directory. */
48
+ stagedLibraryPaths?: string[];
44
49
  targetBinaryPath: string;
45
50
  targetPluginPath: string;
46
51
  backupDir: string;
@@ -1,10 +1,13 @@
1
1
  import { createHash } from "crypto";
2
2
  import { gunzip } from "zlib";
3
3
  import { promisify } from "util";
4
- import { basename, join } from "path";
4
+ import { basename, dirname, join } from "path";
5
5
  import { chmod, copyFile, mkdir, mkdtemp, readFile, rename, rm, stat, writeFile, } from "fs/promises";
6
6
  const gunzipAsync = promisify(gunzip);
7
- export const MACOS_SHERPA_ARCHIVE = "minutes-macos-arm64-sherpa.tar.gz";
7
+ export const MACOS_SHERPA_ARCHIVE = "minutes-macos-arm64-sherpa-shared.tar.gz";
8
+ export const MACOS_LEGACY_SHERPA_ARCHIVE = "minutes-macos-arm64-sherpa.tar.gz";
9
+ /** Shared libraries the plugin loads from its own directory (@loader_path). */
10
+ const MACOS_SHERPA_LIBRARIES = ["libsherpa-onnx-c-api.dylib", "libonnxruntime.dylib"];
8
11
  export const MACOS_BARE_BINARY = "minutes-macos-arm64";
9
12
  export class ReleaseAssetUnavailableError extends Error {
10
13
  assetName;
@@ -62,9 +65,10 @@ function tarSize(header) {
62
65
  return Number.parseInt(raw, 8);
63
66
  }
64
67
  /**
65
- * Extract the two files from the macOS sherpa release archive.
68
+ * Extract the fixed files from the macOS sherpa release archive.
66
69
  *
67
- * The release archive has one fixed directory and two fixed regular files.
70
+ * Both generations use one fixed directory: the CLI and plugin, optionally
71
+ * accompanied by the complete pair of shared libraries. Partial pairs fail.
68
72
  * Keeping this reader deliberately narrow avoids a package dependency and,
69
73
  * more importantly, prevents path traversal, links, devices, or unexpected
70
74
  * files from ever being materialized. The archive itself is SHA-256 verified
@@ -75,9 +79,13 @@ export async function extractMacSherpaArchive(options) {
75
79
  const tar = await gunzipAsync(compressed);
76
80
  const expected = new Map();
77
81
  const root = "minutes-macos-arm64-sherpa";
78
- const expectedNames = new Set([
82
+ const requiredNames = [
79
83
  `${root}/minutes`,
80
84
  `${root}/libminutes_sherpa.dylib`,
85
+ ];
86
+ const expectedNames = new Set([
87
+ ...requiredNames,
88
+ ...MACOS_SHERPA_LIBRARIES.map((name) => `${root}/${name}`),
81
89
  ]);
82
90
  let offset = 0;
83
91
  while (offset + 512 <= tar.length) {
@@ -108,7 +116,10 @@ export async function extractMacSherpaArchive(options) {
108
116
  }
109
117
  offset = dataStart + Math.ceil(size / 512) * 512;
110
118
  }
111
- for (const name of expectedNames) {
119
+ const sharedNames = MACOS_SHERPA_LIBRARIES.map((name) => `${root}/${name}`);
120
+ if (sharedNames.some((name) => expected.has(name)))
121
+ requiredNames.push(...sharedNames);
122
+ for (const name of requiredNames) {
112
123
  if (!expected.has(name)) {
113
124
  throw new Error(`macOS sherpa archive is missing ${name}`);
114
125
  }
@@ -120,7 +131,15 @@ export async function extractMacSherpaArchive(options) {
120
131
  await writeFile(pluginPath, expected.get(`${root}/libminutes_sherpa.dylib`), {
121
132
  mode: 0o755,
122
133
  });
123
- return { binaryPath, pluginPath };
134
+ const libraryPaths = [];
135
+ for (const name of MACOS_SHERPA_LIBRARIES) {
136
+ if (!expected.has(`${root}/${name}`))
137
+ continue;
138
+ const libraryPath = join(options.destDir, name);
139
+ await writeFile(libraryPath, expected.get(`${root}/${name}`), { mode: 0o755 });
140
+ libraryPaths.push(libraryPath);
141
+ }
142
+ return { binaryPath, pluginPath, libraryPaths };
124
143
  }
125
144
  /**
126
145
  * Commit a verified binary/plugin pair. The binary rename is the commit point:
@@ -129,36 +148,54 @@ export async function extractMacSherpaArchive(options) {
129
148
  * completed-but-partial install.
130
149
  */
131
150
  export async function atomicReplaceMacSherpaFiles(options) {
132
- const pluginBackup = join(options.backupDir, "previous-libminutes_sherpa.dylib");
133
- let hadPlugin = false;
134
- try {
135
- await stat(options.targetPluginPath);
136
- hadPlugin = true;
137
- await copyFile(options.targetPluginPath, pluginBackup);
138
- }
139
- catch (error) {
140
- if (error.code !== "ENOENT")
141
- throw error;
142
- }
143
- let pluginReplaced = false;
144
- try {
145
- await rename(options.stagedPluginPath, options.targetPluginPath);
146
- pluginReplaced = true;
147
- await rename(options.stagedBinaryPath, options.targetBinaryPath);
148
- }
149
- catch (error) {
150
- if (pluginReplaced) {
151
- if (hadPlugin) {
152
- await rename(pluginBackup, options.targetPluginPath).catch(() => { });
151
+ // Libraries land beside the plugin under their own names, before the plugin
152
+ // that needs them, so a plugin is never visible without its libraries.
153
+ const targetDir = dirname(options.targetPluginPath);
154
+ const companions = [
155
+ ...(options.stagedLibraryPaths ?? []).map((staged) => ({
156
+ staged,
157
+ target: join(targetDir, basename(staged)),
158
+ })),
159
+ { staged: options.stagedPluginPath, target: options.targetPluginPath },
160
+ ];
161
+ const replaced = [];
162
+ const restore = async () => {
163
+ for (const { target, backup } of replaced.reverse()) {
164
+ if (backup) {
165
+ await rename(backup, target).catch(() => { });
153
166
  }
154
167
  else {
155
- await rm(options.targetPluginPath, { force: true }).catch(() => { });
168
+ await rm(target, { force: true }).catch(() => { });
156
169
  }
157
170
  }
171
+ };
172
+ try {
173
+ for (const [index, { staged, target }] of companions.entries()) {
174
+ const backup = join(options.backupDir, `previous-${index}-${basename(target)}`);
175
+ let hadFile = false;
176
+ try {
177
+ await stat(target);
178
+ hadFile = true;
179
+ await copyFile(target, backup);
180
+ }
181
+ catch (error) {
182
+ if (error.code !== "ENOENT")
183
+ throw error;
184
+ }
185
+ await rename(staged, target);
186
+ replaced.push({ target, backup: hadFile ? backup : null });
187
+ }
188
+ await rename(options.stagedBinaryPath, options.targetBinaryPath);
189
+ }
190
+ catch (error) {
191
+ await restore();
158
192
  throw error;
159
193
  }
160
194
  finally {
161
- await rm(pluginBackup, { force: true }).catch(() => { });
195
+ for (const { backup } of replaced) {
196
+ if (backup)
197
+ await rm(backup, { force: true }).catch(() => { });
198
+ }
162
199
  }
163
200
  }
164
201
  /** Install the signed macOS sherpa archive, falling back only when unavailable. */
@@ -169,20 +206,27 @@ export async function installMacSherpaArchiveWithFallback(options) {
169
206
  await mkdir(options.installDir, { recursive: true });
170
207
  const temporaryDir = await mkdtemp(join(options.installDir, ".minutes-sherpa-install-"));
171
208
  try {
172
- const archivePath = join(temporaryDir, MACOS_SHERPA_ARCHIVE);
173
- try {
174
- await downloadAsset({
175
- binaryName: MACOS_SHERPA_ARCHIVE,
176
- targetPath: archivePath,
177
- execFileAsync: options.execFileAsync,
178
- baseUrl: options.baseUrl,
179
- });
209
+ let assetName;
210
+ let archivePath = "";
211
+ for (const candidate of [MACOS_SHERPA_ARCHIVE, MACOS_LEGACY_SHERPA_ARCHIVE]) {
212
+ archivePath = join(temporaryDir, candidate);
213
+ try {
214
+ await downloadAsset({
215
+ binaryName: candidate,
216
+ targetPath: archivePath,
217
+ execFileAsync: options.execFileAsync,
218
+ baseUrl: options.baseUrl,
219
+ });
220
+ assetName = candidate;
221
+ break;
222
+ }
223
+ catch (error) {
224
+ if (!(error instanceof ReleaseAssetUnavailableError))
225
+ throw error;
226
+ log(`[Minutes] ${candidate} is unavailable in this release; trying the compatible fallback`);
227
+ }
180
228
  }
181
- catch (error) {
182
- if (!(error instanceof ReleaseAssetUnavailableError))
183
- throw error;
184
- log(`[Minutes] ${MACOS_SHERPA_ARCHIVE} is unavailable in this release (${error.message}); ` +
185
- `falling back to the bare ${MACOS_BARE_BINARY} asset`);
229
+ if (!assetName) {
186
230
  const targetBinaryPath = join(options.installDir, "minutes");
187
231
  await downloadAsset({
188
232
  binaryName: MACOS_BARE_BINARY,
@@ -195,7 +239,7 @@ export async function installMacSherpaArchiveWithFallback(options) {
195
239
  }
196
240
  const extractedDir = join(temporaryDir, "extracted");
197
241
  await mkdir(extractedDir, { recursive: true });
198
- const { binaryPath, pluginPath } = await extractArchive({
242
+ const { binaryPath, pluginPath, libraryPaths } = await extractArchive({
199
243
  archivePath,
200
244
  destDir: extractedDir,
201
245
  });
@@ -207,11 +251,12 @@ export async function installMacSherpaArchiveWithFallback(options) {
207
251
  await atomicReplaceMacSherpaFiles({
208
252
  stagedBinaryPath: binaryPath,
209
253
  stagedPluginPath: pluginPath,
254
+ stagedLibraryPaths: libraryPaths,
210
255
  targetBinaryPath: join(options.installDir, "minutes"),
211
256
  targetPluginPath: join(options.installDir, "libminutes_sherpa.dylib"),
212
257
  backupDir: temporaryDir,
213
258
  });
214
- return { assetName: MACOS_SHERPA_ARCHIVE, usedFallback: false };
259
+ return { assetName, usedFallback: assetName !== MACOS_SHERPA_ARCHIVE };
215
260
  }
216
261
  finally {
217
262
  await rm(temporaryDir, { recursive: true, force: true }).catch(() => { });
package/dist/index.js CHANGED
@@ -804,6 +804,13 @@ function withoutContextSourceAuthorization(value) {
804
804
  const { source_authorization: _receipt, ...publicValue } = value;
805
805
  return publicValue;
806
806
  }
807
+ // Relevance tier from minutes-sdk's lexicalMatch, compared before score. The
808
+ // pinned SDK may predate the field; compareSearchMatches then ignores it, and
809
+ // tiers take effect when the release moves the pin.
810
+ function retrievalTier(match) {
811
+ const tier = match?.tier;
812
+ return typeof tier === "number" ? tier : 0;
813
+ }
807
814
  async function policyVerifiedMeetingSnapshots(dir, includeRestricted) {
808
815
  return policySnapshotOperation(dir, includeRestricted, (snapshots) => snapshots);
809
816
  }
@@ -843,8 +850,15 @@ export async function policySearchMeetings(dir, query, limit, includeRestricted,
843
850
  return [];
844
851
  return policyMatchingSnapshotOperation(dir, includeRestricted, (meeting) => reader.lexicalMatch(meeting.frontmatter.title, meeting.body, query) !== null, (snapshots) => {
845
852
  const results = [];
846
- const ranked = snapshots.map((snapshot) => ({ snapshot, score: reader.lexicalMatch(snapshot.meeting.frontmatter.title, snapshot.meeting.body, query)?.score ?? 0 }));
847
- ranked.sort((a, b) => reader.compareSearchMatches({ score: a.score, date: a.snapshot.meeting.frontmatter.date, path: a.snapshot.path }, { score: b.score, date: b.snapshot.meeting.frontmatter.date, path: b.snapshot.path }));
853
+ const ranked = snapshots.map((snapshot) => {
854
+ const match = reader.lexicalMatch(snapshot.meeting.frontmatter.title, snapshot.meeting.body, query);
855
+ return { snapshot, score: match?.score ?? 0, tier: retrievalTier(match) };
856
+ });
857
+ ranked.sort((a, b) => {
858
+ const left = { tier: a.tier, score: a.score, date: a.snapshot.meeting.frontmatter.date, path: a.snapshot.path };
859
+ const right = { tier: b.tier, score: b.score, date: b.snapshot.meeting.frontmatter.date, path: b.snapshot.path };
860
+ return reader.compareSearchMatches(left, right);
861
+ });
848
862
  for (const { snapshot } of ranked) {
849
863
  results.push(snapshot.meeting);
850
864
  if (results.length >= boundedLimit)
@@ -1045,7 +1059,11 @@ export function collectPolicyToolSearchSnapshots(snapshot, includeRestricted, fi
1045
1059
  meeting.retrieval = reader.lexicalMatch(meeting.frontmatter.title, meeting.body, filter.query) ?? undefined;
1046
1060
  matches.push({ path: file.path, content: file.content, meeting });
1047
1061
  }
1048
- return matches.sort((a, b) => reader.compareSearchMatches({ score: a.meeting.retrieval?.score ?? 0, date: a.meeting.frontmatter.date, path: a.path }, { score: b.meeting.retrieval?.score ?? 0, date: b.meeting.frontmatter.date, path: b.path })).slice(0, MCP_POLICY_MEETING_RESULT_MAX);
1062
+ return matches.sort((a, b) => {
1063
+ const left = { tier: retrievalTier(a.meeting.retrieval), score: a.meeting.retrieval?.score ?? 0, date: a.meeting.frontmatter.date, path: a.path };
1064
+ const right = { tier: retrievalTier(b.meeting.retrieval), score: b.meeting.retrieval?.score ?? 0, date: b.meeting.frontmatter.date, path: b.path };
1065
+ return reader.compareSearchMatches(left, right);
1066
+ }).slice(0, MCP_POLICY_MEETING_RESULT_MAX);
1049
1067
  }
1050
1068
  async function policyToolSearchMeetings(dir, includeRestricted, filter, limit = MCP_MEETING_RESULT_MAX) {
1051
1069
  return withStableCorpusLease(dir, (snapshot) => collectPolicyToolSearchSnapshots(snapshot, includeRestricted, filter)
@@ -1597,7 +1615,7 @@ const COPILOT_SUPPORTED = hasFeature(CLI_CAPABILITIES, "copilot_realtime");
1597
1615
  // `./version.ts` (see issue #183). Hosted `.mcpb` bundles will run
1598
1616
  // against CLIs with different minor/patch numbers within the same
1599
1617
  // major; that is explicitly supported.
1600
- const MCP_SERVER_VERSION = "0.30.9";
1618
+ const MCP_SERVER_VERSION = "0.31.0";
1601
1619
  export function parseKnowledgeConfig(configContent) {
1602
1620
  const knowledgeMatch = configContent.match(/\[knowledge\][\s\S]*?(?=\n\[|$)/);
1603
1621
  if (!knowledgeMatch) {