@introspection-ai/recipes 0.24.0 → 0.25.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 (100) hide show
  1. package/README.md +3 -3
  2. package/dist/channels/tools.js +1 -1
  3. package/dist/channels/tools.js.map +1 -1
  4. package/dist/mcp-chunks/{auth-command-4OEOMU2V.js → auth-command-4WFRNU2I.js} +24 -24
  5. package/dist/mcp-chunks/call-arguments-4DWPBLQP.js +15 -0
  6. package/dist/mcp-chunks/{call-command-AUEKSBMD.js → call-command-JBIKXOGC.js} +36 -36
  7. package/dist/mcp-chunks/{chunk-L4CUJJI5.js → chunk-36VIJRYY.js} +4 -4
  8. package/dist/mcp-chunks/{chunk-PPIXUCYQ.js → chunk-3JGS7LQB.js} +2 -2
  9. package/dist/mcp-chunks/{chunk-4NDR45CX.js → chunk-3R2WK3NB.js} +28 -9
  10. package/dist/mcp-chunks/{chunk-YX2NKW6O.js → chunk-3Z7MFS6K.js} +23 -6
  11. package/dist/mcp-chunks/{chunk-ACTRQW5L.js → chunk-4ZNBWL65.js} +2 -2
  12. package/dist/mcp-chunks/chunk-53NRFMB3.js +990 -0
  13. package/dist/mcp-chunks/{chunk-6QH47GNE.js → chunk-6YZW3XAE.js} +68 -6
  14. package/dist/mcp-chunks/{chunk-X3FOKZ5C.js → chunk-7WOKCV6Q.js} +1 -1
  15. package/dist/mcp-chunks/{chunk-MOML5C2E.js → chunk-AD3FQ73K.js} +1 -1
  16. package/dist/mcp-chunks/{chunk-HDUKEFBI.js → chunk-AIKLVBYU.js} +2 -2
  17. package/dist/mcp-chunks/{chunk-SQTXZR56.js → chunk-ASG4OY3M.js} +21 -604
  18. package/dist/mcp-chunks/{chunk-V4RYLZM5.js → chunk-B2LNXGAP.js} +1 -1
  19. package/dist/mcp-chunks/{chunk-XVJAASVZ.js → chunk-BWW4XRUC.js} +16 -16
  20. package/dist/mcp-chunks/{chunk-MRXSXBZT.js → chunk-C2KNLFZR.js} +2 -2
  21. package/dist/mcp-chunks/{chunk-KPXFBRTG.js → chunk-CZKDJZER.js} +1 -1
  22. package/dist/mcp-chunks/{chunk-6CYJ6RN3.js → chunk-DTZHEVKC.js} +1 -1
  23. package/dist/mcp-chunks/{chunk-PLSS6TQZ.js → chunk-ED2WN5BI.js} +3 -3
  24. package/dist/mcp-chunks/{chunk-OGFFBNIC.js → chunk-ELA77TDC.js} +4 -4
  25. package/dist/mcp-chunks/{chunk-5WGJPYOR.js → chunk-EMSNQHZZ.js} +1 -1
  26. package/dist/mcp-chunks/{chunk-AB7MHBEG.js → chunk-EPT4MYOF.js} +11 -11
  27. package/dist/mcp-chunks/{chunk-HHMWZ2FZ.js → chunk-FAJPJTOC.js} +1 -1
  28. package/dist/mcp-chunks/{chunk-TGJOZDKG.js → chunk-FS5JIKT6.js} +2 -2
  29. package/dist/mcp-chunks/{chunk-IPH6U7SE.js → chunk-FX5NYWBH.js} +3 -3
  30. package/dist/mcp-chunks/{chunk-SCGMRUKI.js → chunk-G6OMDUNG.js} +5 -5
  31. package/dist/mcp-chunks/{chunk-47N2EELW.js → chunk-GQ6NSIDS.js} +30 -30
  32. package/dist/mcp-chunks/{chunk-PPOHGQKM.js → chunk-GUXMP7QB.js} +2 -2
  33. package/dist/mcp-chunks/{chunk-NMFI6AUD.js → chunk-H3JCYHGS.js} +25 -25
  34. package/dist/mcp-chunks/{chunk-3VLPWGJL.js → chunk-HCOKLSOB.js} +4 -4
  35. package/dist/mcp-chunks/{chunk-J6VOMOKI.js → chunk-HLRCUHNO.js} +1 -1
  36. package/dist/mcp-chunks/{chunk-LWVFSQYX.js → chunk-HN7WPMCA.js} +7806 -3454
  37. package/dist/mcp-chunks/chunk-I5GI2A2D.js +92 -0
  38. package/dist/mcp-chunks/{chunk-7KEDX7SE.js → chunk-IME7DGLJ.js} +2 -2
  39. package/dist/mcp-chunks/{chunk-E4YYMOT2.js → chunk-IPNSPKQK.js} +33 -21
  40. package/dist/mcp-chunks/{chunk-ZKFG37TB.js → chunk-IRTJXFWA.js} +2 -2
  41. package/dist/mcp-chunks/{chunk-KMH3PHLA.js → chunk-ITCCROID.js} +13 -7
  42. package/dist/mcp-chunks/{chunk-ADINDBOF.js → chunk-ITR7FQM3.js} +2 -2
  43. package/dist/mcp-chunks/{chunk-JILBFEBD.js → chunk-IYWYVHHD.js} +1 -1
  44. package/dist/mcp-chunks/{chunk-RO2Y34XX.js → chunk-JG4TRUPF.js} +1 -1
  45. package/dist/mcp-chunks/{chunk-DEYKPG4K.js → chunk-KW3ANJ36.js} +4 -4
  46. package/dist/mcp-chunks/{chunk-NWLOPQT7.js → chunk-MOEZ43ZL.js} +1 -1
  47. package/dist/mcp-chunks/{chunk-AFKE4BTR.js → chunk-NTHUNCXJ.js} +21 -21
  48. package/dist/mcp-chunks/{chunk-J3J3NQ4X.js → chunk-OD3MSMXY.js} +1 -1
  49. package/dist/mcp-chunks/{chunk-PRZCYXVO.js → chunk-OP3IW2V6.js} +2 -2
  50. package/dist/mcp-chunks/{chunk-K56RW4HB.js → chunk-PZ323CXI.js} +1 -1
  51. package/dist/mcp-chunks/{chunk-US57PK4B.js → chunk-QZUC2T72.js} +59 -4
  52. package/dist/mcp-chunks/{chunk-Z7O6NF7X.js → chunk-RD7NHCRK.js} +19 -19
  53. package/dist/mcp-chunks/{chunk-756YH7S4.js → chunk-RSTKSBVF.js} +2 -2
  54. package/dist/mcp-chunks/{chunk-6DL2C6V5.js → chunk-SCOMDV54.js} +1 -1
  55. package/dist/mcp-chunks/{chunk-SAK5KCLR.js → chunk-SNKXMWDB.js} +1 -1
  56. package/dist/mcp-chunks/{chunk-LC2CCTQN.js → chunk-TF2YTYE4.js} +1 -1
  57. package/dist/mcp-chunks/chunk-TPHPAEDH.js +3769 -0
  58. package/dist/mcp-chunks/{chunk-AF74TOWM.js → chunk-V5AYEKSL.js} +5 -5
  59. package/dist/mcp-chunks/{chunk-HBDCHBJP.js → chunk-WTMJMM3B.js} +12 -1
  60. package/dist/mcp-chunks/{chunk-ZZSD2JT7.js → chunk-WYLHHXI6.js} +1 -1
  61. package/dist/mcp-chunks/{chunk-MFFE5QSH.js → chunk-Y3EDWN2P.js} +1 -1
  62. package/dist/mcp-chunks/{chunk-ZRZ7C6L3.js → chunk-YIRGLKDA.js} +8 -8
  63. package/dist/mcp-chunks/{chunk-RE4EVQNC.js → chunk-ZOAQDFAO.js} +62 -7
  64. package/dist/mcp-chunks/{cli-B7WQQUME.js → cli-XU26MUCN.js} +67 -67
  65. package/dist/mcp-chunks/client-OT34CKRH.js +21 -0
  66. package/dist/mcp-chunks/{config-command-FF3JPMOP.js → config-command-UQMMIK2U.js} +37 -30
  67. package/dist/mcp-chunks/daemon-command-YCIOZGPZ.js +35 -0
  68. package/dist/mcp-chunks/{dist-V4UB7RTR.js → dist-DM2RXZMU.js} +47 -44
  69. package/dist/mcp-chunks/{emit-ts-command-4X56IZ32.js → emit-ts-command-KAOL6DAN.js} +16 -16
  70. package/dist/mcp-chunks/{generate-cli-runner-MIPF73SJ.js → generate-cli-runner-AK6XNRTK.js} +70 -50
  71. package/dist/mcp-chunks/{inspect-cli-command-GX54ZXKR.js → inspect-cli-command-6FVJO7H2.js} +10 -10
  72. package/dist/mcp-chunks/{launch-E2LWGPZS.js → launch-EIT73HX4.js} +1 -1
  73. package/dist/mcp-chunks/{lifecycle-TONHXXXJ.js → lifecycle-QH4TUI3K.js} +1 -1
  74. package/dist/mcp-chunks/{list-command-YUGRZO4G.js → list-command-UOB2XZK7.js} +30 -30
  75. package/dist/mcp-chunks/{output-utils-AZY6N2VQ.js → output-utils-6YXH23T7.js} +3 -3
  76. package/dist/mcp-chunks/{prompt-CH6TK0bC-NSBYYJZH.js → prompt-CH6TK0bC-ZB6RFAXR.js} +1 -1
  77. package/dist/mcp-chunks/{record-command-25DLELA2.js → record-command-FO5TTERC.js} +5 -5
  78. package/dist/mcp-chunks/{replay-command-6SLDG6PC.js → replay-command-SCBPCGQ7.js} +6 -6
  79. package/dist/mcp-chunks/{resource-command-YVOB4JCU.js → resource-command-S2J7XEMV.js} +10 -10
  80. package/dist/mcp-chunks/{result-utils-ZXB5DM36.js → result-utils-OME6HGS6.js} +4 -4
  81. package/dist/mcp-chunks/runtime-QIPMLIJI.js +39 -0
  82. package/dist/mcp-chunks/runtime-wrapper-X4YFKMJI.js +16 -0
  83. package/dist/mcp-chunks/{serve-command-QYGM2AMB.js → serve-command-DDBZZSG6.js} +28 -28
  84. package/dist/mcp-chunks/{timeouts-P3TBB3AX.js → timeouts-HNGNKDQN.js} +3 -3
  85. package/dist/mcp-chunks/{vault-command-VDMPATIX.js → vault-command-TJZYS3YI.js} +8 -7
  86. package/dist/mcp-chunks/{webapi-BLTNWSB2.js → webapi-4GWO2UBA.js} +887 -703
  87. package/dist/mcp-daemon.js +31 -31
  88. package/dist/mcp-run-worker.js +31 -31
  89. package/docs/channels.md +6 -5
  90. package/docs/recipe-format.md +6 -3
  91. package/docs/slack.md +14 -11
  92. package/package.json +11 -11
  93. package/dist/mcp-chunks/call-arguments-RPXZJOXL.js +0 -15
  94. package/dist/mcp-chunks/chunk-7CS27CWE.js +0 -431
  95. package/dist/mcp-chunks/chunk-LJCZWKGJ.js +0 -372
  96. package/dist/mcp-chunks/chunk-Q7ESBNJG.js +0 -57
  97. package/dist/mcp-chunks/client-4ZHIBB67.js +0 -21
  98. package/dist/mcp-chunks/daemon-command-FKW6YELL.js +0 -35
  99. package/dist/mcp-chunks/runtime-NOWGTHZ5.js +0 -39
  100. package/dist/mcp-chunks/runtime-wrapper-ZZPAFQE4.js +0 -14
@@ -1,615 +1,32 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
- clearVaultEntry,
4
- clearVaultTokensIfMatching,
5
- getOAuthVaultPath,
6
- isStoredOAuthClientInformation,
7
- isStoredOAuthTokens,
8
- loadVaultEntryForRecovery,
9
- reconcileVaultServerUrl,
10
- sameOAuthClientGeneration,
11
- sameOAuthClientValue,
3
+ clearLegacyOAuthArtifacts,
4
+ createOAuthPersistenceStores,
12
5
  sameOAuthTokenGeneration,
13
- sameOAuthTokenValue,
14
- saveVaultEntry,
15
- vaultCredentialKeys,
16
- withHiddenOAuthClientGeneration,
17
- withHiddenOAuthTokenGeneration,
18
- withOAuthClientGeneration,
19
- withOAuthTokenGeneration
20
- } from "./chunk-7CS27CWE.js";
6
+ vaultCredentialKeys
7
+ } from "./chunk-53NRFMB3.js";
21
8
  import {
22
9
  checkResourceAllowed,
23
10
  discoverOAuthServerInfo,
24
11
  refreshAuthorization,
25
12
  resourceUrlFromServerUrl
26
- } from "./chunk-K56RW4HB.js";
13
+ } from "./chunk-PZ323CXI.js";
27
14
  import {
28
15
  canonicalizeFilePath,
29
16
  isFileLockTimeoutError,
30
- readJsonFile,
31
- withFileLock,
32
- writeJsonFile,
33
- writeTextFileAtomic
34
- } from "./chunk-ADINDBOF.js";
17
+ withFileLock
18
+ } from "./chunk-ITR7FQM3.js";
35
19
  import {
36
- legacyMcporterDir,
37
20
  mcporterDir
38
- } from "./chunk-TGJOZDKG.js";
21
+ } from "./chunk-FS5JIKT6.js";
39
22
 
40
- // node_modules/.pnpm/mcporter@0.13.7/node_modules/mcporter/dist/oauth-persistence.js
41
- import fs2 from "node:fs/promises";
42
-
43
- // node_modules/.pnpm/mcporter@0.13.7/node_modules/mcporter/dist/oauth-persistence-stores.js
23
+ // node_modules/.pnpm/mcporter@0.13.8/node_modules/mcporter/dist/oauth-persistence.js
44
24
  import fs from "node:fs/promises";
45
- import os from "node:os";
46
- import path from "node:path";
47
- function withStoredExpiry(tokens) {
48
- const stored = tokens;
49
- if (typeof stored.expires_at === "number" || typeof stored.expiresAt === "number") {
50
- return tokens;
51
- }
52
- if (typeof tokens.expires_in === "number" && Number.isFinite(tokens.expires_in)) {
53
- return {
54
- ...tokens,
55
- expires_at: Math.floor(Date.now() / 1e3) + tokens.expires_in
56
- };
57
- }
58
- return tokens;
59
- }
60
- function prepareStoredTokens(tokens) {
61
- return withStoredExpiry(withOAuthTokenGeneration(tokens));
62
- }
63
- var DirectoryPersistence = class {
64
- root;
65
- logger;
66
- serverUrl;
67
- skipUrlMarkerWhenMissing;
68
- tokenPath;
69
- clientInfoPath;
70
- codeVerifierPath;
71
- statePath;
72
- serverUrlPath;
73
- discoveryStatePath;
74
- authorizationServerUrlPath;
75
- resourceUrlPath;
76
- constructor(root, logger, serverUrl, skipUrlMarkerWhenMissing = false) {
77
- this.root = root;
78
- this.logger = logger;
79
- this.serverUrl = serverUrl;
80
- this.skipUrlMarkerWhenMissing = skipUrlMarkerWhenMissing;
81
- this.tokenPath = path.join(root, "tokens.json");
82
- this.clientInfoPath = path.join(root, "client.json");
83
- this.codeVerifierPath = path.join(root, "code_verifier.txt");
84
- this.statePath = path.join(root, "state.txt");
85
- this.serverUrlPath = path.join(root, "server_url.txt");
86
- this.discoveryStatePath = path.join(root, "discovery.json");
87
- this.authorizationServerUrlPath = path.join(root, "authorization_server_url.txt");
88
- this.resourceUrlPath = path.join(root, "resource_url.txt");
89
- }
90
- describe() {
91
- return this.root;
92
- }
93
- async ensureDir() {
94
- await fs.mkdir(this.root, { recursive: true });
95
- }
96
- async reconcileServerUrl() {
97
- if (!this.serverUrl) {
98
- return;
99
- }
100
- const serverUrl = this.serverUrl;
101
- if (this.skipUrlMarkerWhenMissing) {
102
- try {
103
- await fs.access(this.root);
104
- } catch (error) {
105
- if (error.code === "ENOENT") {
106
- return;
107
- }
108
- throw error;
109
- }
110
- }
111
- await this.ensureDir();
112
- await withFileLock(this.tokenPath, async () => {
113
- let previousUrl;
114
- try {
115
- previousUrl = (await fs.readFile(this.serverUrlPath, "utf8")).trim();
116
- } catch (error) {
117
- if (error.code !== "ENOENT") {
118
- throw error;
119
- }
120
- }
121
- if (previousUrl === serverUrl) {
122
- return;
123
- }
124
- if (previousUrl !== void 0) {
125
- await this.clearFiles("all");
126
- }
127
- await writeTextFileAtomic(this.serverUrlPath, serverUrl);
128
- });
129
- }
130
- async readSnapshot() {
131
- await this.reconcileServerUrl();
132
- const [tokens, clientInfo, codeVerifier, state, discoveryState, authorizationServerUrl, resourceUrl] = await Promise.all([
133
- this.readTokensAfterReconcile(),
134
- this.readClientInfoAfterReconcile(),
135
- this.readCodeVerifierAfterReconcile(),
136
- this.readStateAfterReconcile(),
137
- this.readDiscoveryStateAfterReconcile(),
138
- this.readTextAfterReconcile(this.authorizationServerUrlPath),
139
- this.readTextAfterReconcile(this.resourceUrlPath)
140
- ]);
141
- return { tokens, clientInfo, codeVerifier, state, discoveryState, authorizationServerUrl, resourceUrl };
142
- }
143
- async readTokens() {
144
- await this.reconcileServerUrl();
145
- return await this.readTokensAfterReconcile();
146
- }
147
- async readTokensAfterReconcile() {
148
- const tokens = await this.readJsonOrUndefined(this.tokenPath);
149
- return isStoredOAuthTokens(tokens) ? withHiddenOAuthTokenGeneration(tokens) : void 0;
150
- }
151
- async saveTokens(tokens) {
152
- await this.reconcileServerUrl();
153
- await this.ensureDir();
154
- await withFileLock(this.tokenPath, async () => {
155
- await writeJsonFile(this.tokenPath, prepareStoredTokens(tokens));
156
- });
157
- this.logger?.debug?.(`Saved tokens to ${this.tokenPath}`);
158
- }
159
- async clearRejectedCredentials(expectedTokens, expectedClientInfo) {
160
- await this.reconcileServerUrl();
161
- await withFileLock(this.tokenPath, async () => {
162
- if (expectedTokens) {
163
- const current = await this.readJsonOrUndefined(this.tokenPath);
164
- if (sameOAuthTokenGeneration(current, expectedTokens)) {
165
- await this.unlinkIfPresent(this.tokenPath);
166
- }
167
- }
168
- if (expectedClientInfo) {
169
- const currentClientInfo = await this.readJsonOrUndefined(this.clientInfoPath);
170
- if (sameOAuthClientGeneration(currentClientInfo, expectedClientInfo)) {
171
- await this.unlinkIfPresent(this.clientInfoPath);
172
- }
173
- }
174
- });
175
- }
176
- async unlinkIfPresent(file) {
177
- try {
178
- await fs.unlink(file);
179
- } catch (error) {
180
- if (error.code !== "ENOENT") {
181
- throw error;
182
- }
183
- }
184
- }
185
- async readClientInfo() {
186
- await this.reconcileServerUrl();
187
- return await this.readClientInfoAfterReconcile();
188
- }
189
- async readClientInfoAfterReconcile() {
190
- const info = await this.readJsonOrUndefined(this.clientInfoPath);
191
- return isStoredOAuthClientInformation(info) ? withHiddenOAuthClientGeneration(info) : void 0;
192
- }
193
- async saveClientInfo(info) {
194
- await this.reconcileServerUrl();
195
- await this.ensureDir();
196
- await withFileLock(this.tokenPath, async () => {
197
- await writeJsonFile(this.clientInfoPath, withOAuthClientGeneration(info));
198
- });
199
- }
200
- async readCodeVerifier() {
201
- await this.reconcileServerUrl();
202
- return await this.readCodeVerifierAfterReconcile();
203
- }
204
- async readCodeVerifierAfterReconcile() {
205
- try {
206
- return (await fs.readFile(this.codeVerifierPath, "utf8")).trim();
207
- } catch (error) {
208
- if (error.code === "ENOENT") {
209
- return void 0;
210
- }
211
- throw error;
212
- }
213
- }
214
- async saveCodeVerifier(value) {
215
- await this.reconcileServerUrl();
216
- await this.ensureDir();
217
- await writeTextFileAtomic(this.codeVerifierPath, value);
218
- }
219
- async readState() {
220
- await this.reconcileServerUrl();
221
- return await this.readStateAfterReconcile();
222
- }
223
- async readStateAfterReconcile() {
224
- return readJsonFile(this.statePath);
225
- }
226
- // A present-but-corrupt credential cache (tokens/client) means "no usable
227
- // credentials": degrade to re-auth instead of crashing the connection,
228
- // mirroring VaultPersistence and the daemon/server-proxy readers. Genuine I/O
229
- // faults still propagate (readJsonFile re-throws everything except ENOENT).
230
- // OAuth state is intentionally excluded so its CSRF check still fails closed.
231
- async readJsonOrUndefined(filePath) {
232
- try {
233
- return await readJsonFile(filePath);
234
- } catch (error) {
235
- if (!(error instanceof SyntaxError)) {
236
- throw error;
237
- }
238
- this.logger?.debug?.(`Ignoring corrupt OAuth cache file ${filePath}: ${error.message}`);
239
- return void 0;
240
- }
241
- }
242
- async saveState(value) {
243
- await this.reconcileServerUrl();
244
- await this.ensureDir();
245
- await writeJsonFile(this.statePath, value);
246
- }
247
- async readDiscoveryState() {
248
- await this.reconcileServerUrl();
249
- return this.readDiscoveryStateAfterReconcile();
250
- }
251
- async readDiscoveryStateAfterReconcile() {
252
- return readJsonFile(this.discoveryStatePath);
253
- }
254
- async saveDiscoveryState(value) {
255
- await this.reconcileServerUrl();
256
- await this.ensureDir();
257
- await writeJsonFile(this.discoveryStatePath, value);
258
- }
259
- async readAuthorizationServerUrl() {
260
- await this.reconcileServerUrl();
261
- return this.readTextAfterReconcile(this.authorizationServerUrlPath);
262
- }
263
- async saveAuthorizationServerUrl(value) {
264
- await this.reconcileServerUrl();
265
- await this.ensureDir();
266
- await writeTextFileAtomic(this.authorizationServerUrlPath, value);
267
- }
268
- async readResourceUrl() {
269
- await this.reconcileServerUrl();
270
- return this.readTextAfterReconcile(this.resourceUrlPath);
271
- }
272
- async saveResourceUrl(value) {
273
- await this.reconcileServerUrl();
274
- await this.ensureDir();
275
- await writeTextFileAtomic(this.resourceUrlPath, value);
276
- }
277
- async readTextAfterReconcile(filePath) {
278
- try {
279
- return (await fs.readFile(filePath, "utf8")).trim() || void 0;
280
- } catch (error) {
281
- if (error.code === "ENOENT")
282
- return void 0;
283
- throw error;
284
- }
285
- }
286
- async clear(scope) {
287
- await this.reconcileServerUrl();
288
- await this.clearFiles(scope);
289
- }
290
- async clearFiles(scope) {
291
- const files = [];
292
- if (scope === "all" || scope === "tokens") {
293
- files.push(this.tokenPath);
294
- }
295
- if (scope === "all" || scope === "client") {
296
- files.push(this.clientInfoPath);
297
- }
298
- if (scope === "all" || scope === "verifier") {
299
- files.push(this.codeVerifierPath);
300
- }
301
- if (scope === "all" || scope === "state") {
302
- files.push(this.statePath);
303
- }
304
- if (scope === "all" || scope === "discovery") {
305
- files.push(this.discoveryStatePath, this.authorizationServerUrlPath, this.resourceUrlPath);
306
- }
307
- await Promise.all(files.map((file) => this.unlinkIfPresent(file)));
308
- }
309
- };
310
- var VaultPersistence = class {
311
- definition;
312
- tokenSnapshots;
313
- clientSnapshots;
314
- constructor(definition) {
315
- this.definition = definition;
316
- }
317
- describe() {
318
- return `${getOAuthVaultPath()} (vault)`;
319
- }
320
- async reconcileServerUrl() {
321
- await reconcileVaultServerUrl(this.definition);
322
- }
323
- async readSnapshot() {
324
- await this.reconcileServerUrl();
325
- const recovery = await loadVaultEntryForRecovery(this.definition);
326
- this.tokenSnapshots = recovery.tokenSnapshots;
327
- this.clientSnapshots = recovery.clientSnapshots;
328
- return {
329
- tokens: recovery.entry?.tokens,
330
- clientInfo: recovery.entry?.clientInfo,
331
- codeVerifier: recovery.entry?.codeVerifier,
332
- state: recovery.entry?.state,
333
- discoveryState: recovery.entry?.discoveryState,
334
- authorizationServerUrl: recovery.entry?.authorizationServerUrl,
335
- resourceUrl: recovery.entry?.resourceUrl
336
- };
337
- }
338
- async readTokens() {
339
- const snapshot = await this.readSnapshot();
340
- return snapshot.tokens;
341
- }
342
- async saveTokens(tokens) {
343
- await this.reconcileServerUrl();
344
- await saveVaultEntry(this.definition, { tokens: prepareStoredTokens(tokens) });
345
- }
346
- async readClientInfo() {
347
- const snapshot = await this.readSnapshot();
348
- return snapshot.clientInfo;
349
- }
350
- async saveClientInfo(info) {
351
- await this.reconcileServerUrl();
352
- await saveVaultEntry(this.definition, { clientInfo: info });
353
- }
354
- async readCodeVerifier() {
355
- const snapshot = await this.readSnapshot();
356
- return snapshot.codeVerifier;
357
- }
358
- async saveCodeVerifier(value) {
359
- await this.reconcileServerUrl();
360
- await saveVaultEntry(this.definition, { codeVerifier: value });
361
- }
362
- async readState() {
363
- const snapshot = await this.readSnapshot();
364
- return snapshot.state;
365
- }
366
- async saveState(value) {
367
- await this.reconcileServerUrl();
368
- await saveVaultEntry(this.definition, { state: value });
369
- }
370
- async readDiscoveryState() {
371
- return (await this.readSnapshot()).discoveryState;
372
- }
373
- async saveDiscoveryState(value) {
374
- await this.reconcileServerUrl();
375
- await saveVaultEntry(this.definition, { discoveryState: value });
376
- }
377
- async readAuthorizationServerUrl() {
378
- return (await this.readSnapshot()).authorizationServerUrl;
379
- }
380
- async saveAuthorizationServerUrl(value) {
381
- await this.reconcileServerUrl();
382
- await saveVaultEntry(this.definition, { authorizationServerUrl: value });
383
- }
384
- async readResourceUrl() {
385
- return (await this.readSnapshot()).resourceUrl;
386
- }
387
- async saveResourceUrl(value) {
388
- await this.reconcileServerUrl();
389
- await saveVaultEntry(this.definition, { resourceUrl: value });
390
- }
391
- async clear(scope) {
392
- await this.reconcileServerUrl();
393
- await clearVaultEntry(this.definition, scope);
394
- }
395
- async clearRejectedCredentials(expectedTokens, expectedClientInfo) {
396
- await this.reconcileServerUrl();
397
- await clearVaultTokensIfMatching(this.definition, expectedTokens, expectedClientInfo, expectedTokens ? this.tokenSnapshots : void 0, expectedClientInfo ? this.clientSnapshots : void 0);
398
- }
399
- };
400
- var CompositePersistence = class {
401
- stores;
402
- recoveryTokenSnapshots = /* @__PURE__ */ new Map();
403
- recoveryClientSnapshots = /* @__PURE__ */ new Map();
404
- recoveryTokenSource;
405
- recoveryClientSource;
406
- constructor(stores) {
407
- this.stores = stores;
408
- }
409
- describe() {
410
- return this.stores.map((store) => store.describe()).join(" + ");
411
- }
412
- async readSnapshot() {
413
- const snapshots = await Promise.all(this.stores.map((store) => store.readSnapshot()));
414
- const tokens = this.firstSnapshotValue(snapshots, "tokens");
415
- const clientInfo = this.firstSnapshotValue(snapshots, "clientInfo");
416
- this.recoveryTokenSnapshots.clear();
417
- this.recoveryClientSnapshots.clear();
418
- for (const [index, snapshot] of snapshots.entries()) {
419
- const store = this.stores[index];
420
- this.recoveryTokenSnapshots.set(store, snapshot.tokens);
421
- this.recoveryClientSnapshots.set(store, snapshot.clientInfo);
422
- }
423
- this.recoveryTokenSource = tokens.source;
424
- this.recoveryClientSource = clientInfo.source;
425
- return {
426
- tokens: tokens.value,
427
- clientInfo: clientInfo.value,
428
- codeVerifier: this.firstSnapshotValue(snapshots, "codeVerifier").value,
429
- state: this.firstSnapshotValue(snapshots, "state").value,
430
- discoveryState: this.firstSnapshotValue(snapshots, "discoveryState").value,
431
- authorizationServerUrl: this.firstSnapshotValue(snapshots, "authorizationServerUrl").value,
432
- resourceUrl: this.firstSnapshotValue(snapshots, "resourceUrl").value
433
- };
434
- }
435
- firstSnapshotValue(snapshots, field) {
436
- for (const [index, snapshot] of snapshots.entries()) {
437
- if (snapshot[field] !== void 0) {
438
- return { value: snapshot[field], source: this.stores[index] };
439
- }
440
- }
441
- return { value: void 0, source: void 0 };
442
- }
443
- async readTokens() {
444
- const result = await this.readRecoveryValues((store) => store.readTokens(), this.recoveryTokenSnapshots);
445
- this.recoveryTokenSource = result.source;
446
- return result.value;
447
- }
448
- async readTokensPerStore() {
449
- const perStore = await Promise.all(this.stores.map((store) => store.readTokens()));
450
- return perStore.filter((tokens) => tokens !== void 0);
451
- }
452
- async saveTokens(tokens) {
453
- const stored = prepareStoredTokens(tokens);
454
- await Promise.all(this.stores.map((store) => store.saveTokens(stored)));
455
- }
456
- async clearRejectedCredentials(expectedTokens, expectedClientInfo) {
457
- await Promise.all(this.stores.map((store) => {
458
- const storedTokenSnapshot = expectedTokens ? this.recoveryTokenSnapshots.get(store) : void 0;
459
- const tokenSnapshot = expectedTokens && storedTokenSnapshot && (store === this.recoveryTokenSource || sameOAuthTokenValue(storedTokenSnapshot, expectedTokens)) ? storedTokenSnapshot : void 0;
460
- const storedClientSnapshot = expectedClientInfo ? this.recoveryClientSnapshots.get(store) : void 0;
461
- const clientSnapshot = expectedClientInfo && storedClientSnapshot && (store === this.recoveryClientSource || sameOAuthClientValue(storedClientSnapshot, expectedClientInfo)) ? storedClientSnapshot : void 0;
462
- return tokenSnapshot || clientSnapshot ? store.clearRejectedCredentials(tokenSnapshot, clientSnapshot) : Promise.resolve();
463
- }));
464
- }
465
- async readClientInfo() {
466
- const result = await this.readRecoveryValues((store) => store.readClientInfo(), this.recoveryClientSnapshots);
467
- this.recoveryClientSource = result.source;
468
- return result.value;
469
- }
470
- async readRecoveryValues(read, snapshots) {
471
- const results = await Promise.allSettled(this.stores.map((store) => read(store)));
472
- snapshots.clear();
473
- let value;
474
- let source;
475
- for (const [index, result] of results.entries()) {
476
- const store = this.stores[index];
477
- if (result.status === "rejected") {
478
- if (!source) {
479
- throw result.reason;
480
- }
481
- continue;
482
- }
483
- snapshots.set(store, result.value);
484
- if (!source && result.value !== void 0) {
485
- source = store;
486
- value = result.value;
487
- }
488
- }
489
- return { value, source };
490
- }
491
- async saveClientInfo(info) {
492
- const stored = withOAuthClientGeneration(info);
493
- await Promise.all(this.stores.map((store) => store.saveClientInfo(stored)));
494
- }
495
- async readCodeVerifier() {
496
- for (const store of this.stores) {
497
- const result = await store.readCodeVerifier();
498
- if (result) {
499
- return result;
500
- }
501
- }
502
- return void 0;
503
- }
504
- async saveCodeVerifier(value) {
505
- await Promise.all(this.stores.map((store) => store.saveCodeVerifier(value)));
506
- }
507
- async readState() {
508
- for (const store of this.stores) {
509
- const result = await store.readState();
510
- if (result) {
511
- return result;
512
- }
513
- }
514
- return void 0;
515
- }
516
- async saveState(value) {
517
- await Promise.all(this.stores.map((store) => store.saveState(value)));
518
- }
519
- async readDiscoveryState() {
520
- return this.readFirst((store) => store.readDiscoveryState());
521
- }
522
- async saveDiscoveryState(value) {
523
- await Promise.all(this.stores.map((store) => store.saveDiscoveryState(value)));
524
- }
525
- async readAuthorizationServerUrl() {
526
- return this.readFirst((store) => store.readAuthorizationServerUrl());
527
- }
528
- async saveAuthorizationServerUrl(value) {
529
- await Promise.all(this.stores.map((store) => store.saveAuthorizationServerUrl(value)));
530
- }
531
- async readResourceUrl() {
532
- return this.readFirst((store) => store.readResourceUrl());
533
- }
534
- async saveResourceUrl(value) {
535
- await Promise.all(this.stores.map((store) => store.saveResourceUrl(value)));
536
- }
537
- async readFirst(read) {
538
- for (const store of this.stores) {
539
- const value = await read(store);
540
- if (value !== void 0)
541
- return value;
542
- }
543
- return void 0;
544
- }
545
- async clear(scope) {
546
- await Promise.all(this.stores.map((store) => store.clear(scope)));
547
- }
548
- };
549
- async function createOAuthPersistenceStores(definition, logger) {
550
- const vault = new VaultPersistence(definition);
551
- const stores = [vault];
552
- const serverUrl = definition.command.kind === "http" ? definition.command.url.toString() : void 0;
553
- if (definition.tokenCacheDir) {
554
- stores.unshift(new DirectoryPersistence(definition.tokenCacheDir, logger, serverUrl));
555
- }
556
- const legacyDir = path.join(legacyMcporterDir(), definition.name);
557
- if (!definition.tokenCacheDir) {
558
- const legacy = new DirectoryPersistence(legacyDir, logger, serverUrl, true);
559
- const snapshot = await legacy.readSnapshot();
560
- if (snapshot.tokens || snapshot.clientInfo || snapshot.codeVerifier || snapshot.state || snapshot.discoveryState || snapshot.authorizationServerUrl || snapshot.resourceUrl) {
561
- if (snapshot.tokens) {
562
- await vault.saveTokens(snapshot.tokens);
563
- }
564
- if (snapshot.clientInfo) {
565
- await vault.saveClientInfo(snapshot.clientInfo);
566
- }
567
- if (snapshot.codeVerifier) {
568
- await vault.saveCodeVerifier(snapshot.codeVerifier);
569
- }
570
- if (snapshot.state) {
571
- await vault.saveState(snapshot.state);
572
- }
573
- if (snapshot.discoveryState) {
574
- await vault.saveDiscoveryState(snapshot.discoveryState);
575
- }
576
- if (snapshot.authorizationServerUrl) {
577
- await vault.saveAuthorizationServerUrl(snapshot.authorizationServerUrl);
578
- }
579
- if (snapshot.resourceUrl) {
580
- await vault.saveResourceUrl(snapshot.resourceUrl);
581
- }
582
- logger?.info?.(`Migrated legacy OAuth cache for '${definition.name}' into vault.`);
583
- }
584
- }
585
- return stores.length === 1 ? vault : new CompositePersistence(stores);
586
- }
587
- async function clearLegacyOAuthArtifacts(definition, logger, scope) {
588
- const legacyDir = path.join(legacyMcporterDir(), definition.name);
589
- if (!definition.tokenCacheDir || legacyDir !== definition.tokenCacheDir) {
590
- const legacy = new DirectoryPersistence(legacyDir, logger);
591
- await legacy.clear(scope);
592
- }
593
- const legacyFiles = [];
594
- if (definition.name.toLowerCase() === "gmail") {
595
- legacyFiles.push(path.join(os.homedir(), ".gmail-mcp", "credentials.json"));
596
- }
597
- await Promise.all(legacyFiles.map(async (file) => {
598
- try {
599
- await fs.unlink(file);
600
- logger?.info?.(`Cleared legacy OAuth cache file ${file}`);
601
- } catch (error) {
602
- if (error.code !== "ENOENT") {
603
- throw error;
604
- }
605
- }
606
- }));
607
- }
608
25
 
609
- // node_modules/.pnpm/mcporter@0.13.7/node_modules/mcporter/dist/oauth-token-refresh.js
26
+ // node_modules/.pnpm/mcporter@0.13.8/node_modules/mcporter/dist/oauth-token-refresh.js
610
27
  import { Buffer } from "node:buffer";
611
28
 
612
- // node_modules/.pnpm/mcporter@0.13.7/node_modules/mcporter/dist/oauth-client-info.js
29
+ // node_modules/.pnpm/mcporter@0.13.8/node_modules/mcporter/dist/oauth-client-info.js
613
30
  function buildStaticClientInformation(definition, options = {}) {
614
31
  if (!definition.oauthClientId) {
615
32
  return void 0;
@@ -635,23 +52,23 @@ function resolveOAuthClientSecret(definition, options = {}) {
635
52
  return definition.oauthClientSecret;
636
53
  }
637
54
 
638
- // node_modules/.pnpm/mcporter@0.13.7/node_modules/mcporter/dist/oauth-refresh-lock.js
55
+ // node_modules/.pnpm/mcporter@0.13.8/node_modules/mcporter/dist/oauth-refresh-lock.js
639
56
  import { AsyncLocalStorage } from "node:async_hooks";
640
57
  import crypto from "node:crypto";
641
- import path2 from "node:path";
58
+ import path from "node:path";
642
59
  var REFRESH_LOCK_DIR = "refresh-locks";
643
60
  var LOCK_LABEL_MAX = 40;
644
61
  var IDENTITY_HASH_LENGTH = 16;
645
62
  var TIMEOUT_OVERRIDE_ENV = "MCPORTER_TEST_REFRESH_LOCK_TIMEOUT_MS";
646
63
  var heldLockPaths = new AsyncLocalStorage();
647
64
  function refreshLockDir() {
648
- return path2.join(mcporterDir("data"), REFRESH_LOCK_DIR);
65
+ return path.join(mcporterDir("data"), REFRESH_LOCK_DIR);
649
66
  }
650
67
  async function refreshLockPaths(definition) {
651
68
  const paths = [];
652
69
  if (definition.tokenCacheDir) {
653
- const tokenPath = await canonicalizeFilePath(path2.join(definition.tokenCacheDir, "tokens.json"));
654
- paths.push(lockPathFor(path2.basename(path2.dirname(tokenPath)), `dir:${tokenPath}`));
70
+ const tokenPath = await canonicalizeFilePath(path.join(definition.tokenCacheDir, "tokens.json"));
71
+ paths.push(lockPathFor(path.basename(path.dirname(tokenPath)), `dir:${tokenPath}`));
655
72
  }
656
73
  for (const vaultKey of await vaultCredentialKeys(definition)) {
657
74
  paths.push(lockPathFor(vaultKey.split("|")[0] ?? "", `vault:${vaultKey}`));
@@ -690,15 +107,15 @@ function resolveTimeoutMs(explicit) {
690
107
  return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
691
108
  }
692
109
  function lockPathFor(label, identity) {
693
- const digest = crypto.createHash("sha256").update(identity).digest("hex").slice(0, IDENTITY_HASH_LENGTH);
110
+ const digest = crypto.hash("sha256", identity, "hex").slice(0, IDENTITY_HASH_LENGTH);
694
111
  const safeLabel = filenameSafeLabel(label);
695
- return path2.join(refreshLockDir(), safeLabel.length > 0 ? `${safeLabel}-${digest}` : digest);
112
+ return path.join(refreshLockDir(), safeLabel.length > 0 ? `${safeLabel}-${digest}` : digest);
696
113
  }
697
114
  function filenameSafeLabel(value) {
698
115
  return value.replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^[._-]+/, "").slice(0, LOCK_LABEL_MAX);
699
116
  }
700
117
 
701
- // node_modules/.pnpm/mcporter@0.13.7/node_modules/mcporter/dist/oauth-token-refresh.js
118
+ // node_modules/.pnpm/mcporter@0.13.8/node_modules/mcporter/dist/oauth-token-refresh.js
702
119
  var TOKEN_EXPIRY_SKEW_SECONDS = 60;
703
120
  var TOKEN_REQUEST_TIMEOUT_MS = 1e4;
704
121
  var OAuthIssuerMismatchError = class extends Error {
@@ -1093,7 +510,7 @@ function readClientSecret(definition, refreshClientSecretEnv) {
1093
510
  return resolveOAuthClientSecret(definition, { rejectBlank: true });
1094
511
  }
1095
512
 
1096
- // node_modules/.pnpm/mcporter@0.13.7/node_modules/mcporter/dist/oauth-persistence.js
513
+ // node_modules/.pnpm/mcporter@0.13.8/node_modules/mcporter/dist/oauth-persistence.js
1097
514
  async function buildOAuthPersistence(definition, logger) {
1098
515
  return await createOAuthPersistenceStores(definition, logger);
1099
516
  }
@@ -1101,7 +518,7 @@ async function clearOAuthCaches(definition, logger, scope = "all") {
1101
518
  const persistence = await buildOAuthPersistence(definition, logger);
1102
519
  await persistence.clear(scope);
1103
520
  if (definition.tokenCacheDir && scope === "all") {
1104
- await fs2.rm(definition.tokenCacheDir, { recursive: true, force: true });
521
+ await fs.rm(definition.tokenCacheDir, { recursive: true, force: true });
1105
522
  }
1106
523
  await clearLegacyOAuthArtifacts(definition, logger, scope);
1107
524
  }
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
 
3
- // node_modules/.pnpm/mcporter@0.13.7/node_modules/mcporter/dist/stable-json.js
3
+ // node_modules/.pnpm/mcporter@0.13.8/node_modules/mcporter/dist/stable-json.js
4
4
  function stableJsonStringify(value, space) {
5
5
  const json = JSON.stringify(sortJsonValue(value), void 0, space);
6
6
  if (json === void 0) {