@hasna/connectors 1.4.4 → 1.4.5
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.
- package/README.md +3 -3
- package/bin/index.js +416 -306
- package/bin/mcp.js +297 -187
- package/bin/serve.js +349 -239
- package/connectors/aws/package.json +1 -1
- package/connectors/clickbank/package.json +1 -1
- package/dist/db/database.d.ts +5 -2
- package/dist/index.js +243 -138
- package/dist/lib/paths.d.ts +28 -0
- package/dist/lib/paths.test.d.ts +1 -0
- package/package.json +2 -1
package/bin/mcp.js
CHANGED
|
@@ -4999,10 +4999,118 @@ Commands:
|
|
|
4999
4999
|
});
|
|
5000
5000
|
});
|
|
5001
5001
|
|
|
5002
|
-
//
|
|
5003
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, writeFileSync } from "fs";
|
|
5002
|
+
// ../../node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
|
|
5004
5003
|
import { homedir } from "os";
|
|
5005
|
-
import {
|
|
5004
|
+
import { join as join2 } from "path";
|
|
5005
|
+
function assertApp(app) {
|
|
5006
|
+
if (typeof app !== "string" || app.length === 0) {
|
|
5007
|
+
throw new TypeError("paths: app must be a non-empty string");
|
|
5008
|
+
}
|
|
5009
|
+
if (!APP_SLUG_RE.test(app)) {
|
|
5010
|
+
throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
5013
|
+
function envOf(options) {
|
|
5014
|
+
return options.env ?? process.env;
|
|
5015
|
+
}
|
|
5016
|
+
function envValue(options, kind) {
|
|
5017
|
+
const value = envOf(options)[KIND_ENV[kind]];
|
|
5018
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
5019
|
+
}
|
|
5020
|
+
function isMacOS(platform) {
|
|
5021
|
+
return platform === "darwin";
|
|
5022
|
+
}
|
|
5023
|
+
function baseDir(kind, options) {
|
|
5024
|
+
const override = envValue(options, kind);
|
|
5025
|
+
if (override)
|
|
5026
|
+
return override;
|
|
5027
|
+
const home = options.home ?? homedir();
|
|
5028
|
+
const platform = options.platform ?? process.platform;
|
|
5029
|
+
if (isMacOS(platform)) {
|
|
5030
|
+
switch (kind) {
|
|
5031
|
+
case "config":
|
|
5032
|
+
case "data":
|
|
5033
|
+
return join2(home, "Library", "Application Support", "Hasna");
|
|
5034
|
+
case "cache":
|
|
5035
|
+
return join2(home, "Library", "Caches", "Hasna");
|
|
5036
|
+
case "state":
|
|
5037
|
+
return join2(home, "Library", "Logs", "Hasna");
|
|
5038
|
+
}
|
|
5039
|
+
}
|
|
5040
|
+
switch (kind) {
|
|
5041
|
+
case "config":
|
|
5042
|
+
return join2(home, ".config", "hasna");
|
|
5043
|
+
case "data":
|
|
5044
|
+
return join2(home, ".local", "share", "hasna");
|
|
5045
|
+
case "state":
|
|
5046
|
+
return join2(home, ".local", "state", "hasna");
|
|
5047
|
+
case "cache":
|
|
5048
|
+
return join2(home, ".cache", "hasna");
|
|
5049
|
+
}
|
|
5050
|
+
}
|
|
5051
|
+
function resolvePath(kind, options) {
|
|
5052
|
+
assertApp(options.app);
|
|
5053
|
+
const appSegment = options.internal === true ? join2("internal", options.app) : options.app;
|
|
5054
|
+
return join2(baseDir(kind, options), appSegment);
|
|
5055
|
+
}
|
|
5056
|
+
function dataDir(options) {
|
|
5057
|
+
return resolvePath("data", options);
|
|
5058
|
+
}
|
|
5059
|
+
var KIND_ENV, APP_SLUG_RE;
|
|
5060
|
+
var init_dist = __esm(() => {
|
|
5061
|
+
KIND_ENV = {
|
|
5062
|
+
config: "HASNA_CONFIG_HOME",
|
|
5063
|
+
data: "HASNA_DATA_HOME",
|
|
5064
|
+
state: "HASNA_STATE_HOME",
|
|
5065
|
+
cache: "HASNA_CACHE_HOME"
|
|
5066
|
+
};
|
|
5067
|
+
APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
5068
|
+
});
|
|
5069
|
+
|
|
5070
|
+
// src/lib/paths.ts
|
|
5071
|
+
import { existsSync as existsSync2 } from "fs";
|
|
5072
|
+
import { homedir as homedir2 } from "os";
|
|
5073
|
+
import { join as join3, resolve } from "path";
|
|
5074
|
+
function envOr(name, fallback) {
|
|
5075
|
+
const value = process.env[name]?.trim();
|
|
5076
|
+
return value ? value : fallback;
|
|
5077
|
+
}
|
|
5078
|
+
function effectiveHome() {
|
|
5079
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir2();
|
|
5080
|
+
}
|
|
5081
|
+
function legacyHomeDir() {
|
|
5082
|
+
return join3(effectiveHome(), ".hasna", "connectors");
|
|
5083
|
+
}
|
|
5084
|
+
function resolverHome() {
|
|
5085
|
+
return dataDir({
|
|
5086
|
+
app: "connectors",
|
|
5087
|
+
home: process.env["HOME"] || process.env["USERPROFILE"] || undefined
|
|
5088
|
+
});
|
|
5089
|
+
}
|
|
5090
|
+
function adoptResolverHome(resolved, env = process.env) {
|
|
5091
|
+
const dataOverride = env.HASNA_DATA_HOME;
|
|
5092
|
+
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
5093
|
+
return true;
|
|
5094
|
+
return existsSync2(join3(resolved, "connectors.db"));
|
|
5095
|
+
}
|
|
5096
|
+
function exactConnectorsHome() {
|
|
5097
|
+
const home = envOr("HASNA_CONNECTORS_DIR", "");
|
|
5098
|
+
return home ? home : undefined;
|
|
5099
|
+
}
|
|
5100
|
+
function connectorsHome() {
|
|
5101
|
+
const exact = exactConnectorsHome();
|
|
5102
|
+
if (exact)
|
|
5103
|
+
return resolve(exact);
|
|
5104
|
+
const resolved = resolverHome();
|
|
5105
|
+
return adoptResolverHome(resolved) ? resolve(resolved) : resolve(legacyHomeDir());
|
|
5106
|
+
}
|
|
5107
|
+
var init_paths = __esm(() => {
|
|
5108
|
+
init_dist();
|
|
5109
|
+
});
|
|
5110
|
+
|
|
5111
|
+
// src/core/connectors/gmail.ts
|
|
5112
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync, readdirSync, writeFileSync } from "fs";
|
|
5113
|
+
import { basename, join as join4 } from "path";
|
|
5006
5114
|
async function modifyMessage(profile, messageId, addLabelIds, removeLabelIds) {
|
|
5007
5115
|
return requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}/modify`, {}, {
|
|
5008
5116
|
method: "POST",
|
|
@@ -5039,7 +5147,7 @@ async function replyToMessage(profile, messageId, input) {
|
|
|
5039
5147
|
}
|
|
5040
5148
|
async function downloadAttachments(profile, input) {
|
|
5041
5149
|
const messageId = getMessageId(input);
|
|
5042
|
-
const outputDir = input.dir ?? input.outputDir ??
|
|
5150
|
+
const outputDir = input.dir ?? input.outputDir ?? join4(configDirs()[0], "attachments", messageId);
|
|
5043
5151
|
mkdirSync(outputDir, { recursive: true });
|
|
5044
5152
|
const attachments = input.attachmentId && input.filename ? [{
|
|
5045
5153
|
attachmentId: input.attachmentId,
|
|
@@ -5051,7 +5159,7 @@ async function downloadAttachments(profile, input) {
|
|
|
5051
5159
|
for (const attachment of attachments) {
|
|
5052
5160
|
const data = await requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachment.attachmentId)}`, {});
|
|
5053
5161
|
const filename = safeFilename(attachment.filename);
|
|
5054
|
-
const path =
|
|
5162
|
+
const path = join4(outputDir, filename);
|
|
5055
5163
|
const buffer = Buffer.from(data.data, "base64url");
|
|
5056
5164
|
writeFileSync(path, buffer);
|
|
5057
5165
|
downloaded.push({
|
|
@@ -5121,7 +5229,7 @@ function gmailBackoffDelayMs(attempt, retryAfter = null) {
|
|
|
5121
5229
|
return Math.min(2 ** attempt * baseMs + jitterMs, 64000);
|
|
5122
5230
|
}
|
|
5123
5231
|
function sleep(ms) {
|
|
5124
|
-
return new Promise((
|
|
5232
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
5125
5233
|
}
|
|
5126
5234
|
async function getValidAccessToken(profile) {
|
|
5127
5235
|
if (process.env.GMAIL_ACCESS_TOKEN)
|
|
@@ -5167,9 +5275,9 @@ async function refreshAccessToken(profile, currentTokens) {
|
|
|
5167
5275
|
}
|
|
5168
5276
|
function listProfiles() {
|
|
5169
5277
|
const profiles = new Set;
|
|
5170
|
-
for (const
|
|
5171
|
-
const profilesDir =
|
|
5172
|
-
if (!
|
|
5278
|
+
for (const baseDir2 of configDirs()) {
|
|
5279
|
+
const profilesDir = join4(baseDir2, "profiles");
|
|
5280
|
+
if (!existsSync3(profilesDir))
|
|
5173
5281
|
continue;
|
|
5174
5282
|
for (const entry of readdirSync(profilesDir, { withFileTypes: true })) {
|
|
5175
5283
|
if (entry.isDirectory())
|
|
@@ -5185,10 +5293,10 @@ function loadCredentials(profile) {
|
|
|
5185
5293
|
const envClientSecret = process.env.GMAIL_CLIENT_SECRET ?? process.env.GOOGLE_CLIENT_SECRET;
|
|
5186
5294
|
if (envClientId && envClientSecret)
|
|
5187
5295
|
return { clientId: envClientId, clientSecret: envClientSecret };
|
|
5188
|
-
for (const
|
|
5296
|
+
for (const baseDir2 of configDirs()) {
|
|
5189
5297
|
const credentials = {
|
|
5190
|
-
...readJson(
|
|
5191
|
-
...readJson(
|
|
5298
|
+
...readJson(join4(baseDir2, "credentials.json")),
|
|
5299
|
+
...readJson(join4(baseDir2, "profiles", profile, "config.json"))
|
|
5192
5300
|
};
|
|
5193
5301
|
if (credentials.clientId || credentials.clientSecret)
|
|
5194
5302
|
return credentials;
|
|
@@ -5196,31 +5304,31 @@ function loadCredentials(profile) {
|
|
|
5196
5304
|
return {};
|
|
5197
5305
|
}
|
|
5198
5306
|
function loadTokens(profile) {
|
|
5199
|
-
for (const
|
|
5200
|
-
const fromProfile = readJson(
|
|
5307
|
+
for (const baseDir2 of configDirs()) {
|
|
5308
|
+
const fromProfile = readJson(join4(baseDir2, "profiles", profile, "tokens.json"));
|
|
5201
5309
|
if (fromProfile)
|
|
5202
5310
|
return fromProfile;
|
|
5203
|
-
const flat = readJson(
|
|
5311
|
+
const flat = readJson(join4(baseDir2, "profiles", `${profile}.json`));
|
|
5204
5312
|
if (flat)
|
|
5205
5313
|
return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
|
|
5206
5314
|
}
|
|
5207
5315
|
return null;
|
|
5208
5316
|
}
|
|
5209
5317
|
function saveTokens(profile, tokens) {
|
|
5210
|
-
const
|
|
5211
|
-
const profileDir =
|
|
5318
|
+
const baseDir2 = configDirs().find((dir) => existsSync3(dir)) ?? configDirs()[0];
|
|
5319
|
+
const profileDir = join4(baseDir2, "profiles", profile);
|
|
5212
5320
|
mkdirSync(profileDir, { recursive: true });
|
|
5213
|
-
writeFileSync(
|
|
5321
|
+
writeFileSync(join4(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
5214
5322
|
}
|
|
5215
5323
|
function configDirs() {
|
|
5216
5324
|
const explicit = process.env.HASNA_GMAIL_CONNECTOR_DIR ?? process.env.GMAIL_CONNECTOR_DIR;
|
|
5217
5325
|
if (explicit)
|
|
5218
5326
|
return [explicit];
|
|
5219
|
-
const
|
|
5220
|
-
return [
|
|
5327
|
+
const baseDir2 = connectorsHome();
|
|
5328
|
+
return [join4(baseDir2, "gmail"), join4(baseDir2, "connect-gmail")];
|
|
5221
5329
|
}
|
|
5222
5330
|
function readJson(path) {
|
|
5223
|
-
if (!
|
|
5331
|
+
if (!existsSync3(path))
|
|
5224
5332
|
return null;
|
|
5225
5333
|
try {
|
|
5226
5334
|
return JSON.parse(readFileSync(path, "utf8"));
|
|
@@ -5301,6 +5409,7 @@ function safeFilename(filename) {
|
|
|
5301
5409
|
}
|
|
5302
5410
|
var GMAIL_API_BASE = "https://gmail.googleapis.com/gmail/v1", TOKEN_URL = "https://oauth2.googleapis.com/token", REFRESH_BUFFER_MS, MAX_GMAIL_RETRIES = 5, listMessagesSchema, messageIdSchema, readMessageSchema, attachmentListSchema, attachmentDownloadSchema, historyListSchema, replySchema, gmailConnector;
|
|
5303
5411
|
var init_gmail = __esm(() => {
|
|
5412
|
+
init_paths();
|
|
5304
5413
|
init_zod();
|
|
5305
5414
|
init_connector();
|
|
5306
5415
|
REFRESH_BUFFER_MS = 5 * 60 * 1000;
|
|
@@ -5470,9 +5579,8 @@ var init_gmail = __esm(() => {
|
|
|
5470
5579
|
});
|
|
5471
5580
|
|
|
5472
5581
|
// src/core/connectors/googledrive.ts
|
|
5473
|
-
import { existsSync as
|
|
5474
|
-
import {
|
|
5475
|
-
import { basename as basename2, join as join3 } from "path";
|
|
5582
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
5583
|
+
import { basename as basename2, join as join5 } from "path";
|
|
5476
5584
|
async function requestJson2(profile, path, params) {
|
|
5477
5585
|
const response = await request(profile, path, params);
|
|
5478
5586
|
const text = await response.text();
|
|
@@ -5539,9 +5647,9 @@ async function refreshAccessToken2(profile, currentTokens) {
|
|
|
5539
5647
|
}
|
|
5540
5648
|
function listProfiles2() {
|
|
5541
5649
|
const profiles = new Set;
|
|
5542
|
-
for (const
|
|
5543
|
-
const profilesDir =
|
|
5544
|
-
if (!
|
|
5650
|
+
for (const baseDir2 of configDirs2()) {
|
|
5651
|
+
const profilesDir = join5(baseDir2, "profiles");
|
|
5652
|
+
if (!existsSync4(profilesDir))
|
|
5545
5653
|
continue;
|
|
5546
5654
|
for (const entry of readdirSync2(profilesDir, { withFileTypes: true })) {
|
|
5547
5655
|
if (entry.isDirectory())
|
|
@@ -5586,10 +5694,10 @@ function loadCredentials2(profile) {
|
|
|
5586
5694
|
const envClientSecret = process.env.GOOGLE_CLIENT_SECRET;
|
|
5587
5695
|
if (envClientId && envClientSecret)
|
|
5588
5696
|
return { clientId: envClientId, clientSecret: envClientSecret };
|
|
5589
|
-
for (const
|
|
5697
|
+
for (const baseDir2 of configDirs2()) {
|
|
5590
5698
|
const credentials = {
|
|
5591
|
-
...readJson2(
|
|
5592
|
-
...readJson2(
|
|
5699
|
+
...readJson2(join5(baseDir2, "credentials.json")),
|
|
5700
|
+
...readJson2(join5(baseDir2, "profiles", profile, "config.json"))
|
|
5593
5701
|
};
|
|
5594
5702
|
if (credentials.clientId || credentials.clientSecret)
|
|
5595
5703
|
return credentials;
|
|
@@ -5597,31 +5705,31 @@ function loadCredentials2(profile) {
|
|
|
5597
5705
|
return {};
|
|
5598
5706
|
}
|
|
5599
5707
|
function loadTokens2(profile) {
|
|
5600
|
-
for (const
|
|
5601
|
-
const fromProfile = readJson2(
|
|
5708
|
+
for (const baseDir2 of configDirs2()) {
|
|
5709
|
+
const fromProfile = readJson2(join5(baseDir2, "profiles", profile, "tokens.json"));
|
|
5602
5710
|
if (fromProfile)
|
|
5603
5711
|
return fromProfile;
|
|
5604
|
-
const flat = readJson2(
|
|
5712
|
+
const flat = readJson2(join5(baseDir2, "profiles", `${profile}.json`));
|
|
5605
5713
|
if (flat)
|
|
5606
5714
|
return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
|
|
5607
5715
|
}
|
|
5608
5716
|
return null;
|
|
5609
5717
|
}
|
|
5610
5718
|
function saveTokens2(profile, tokens) {
|
|
5611
|
-
const
|
|
5612
|
-
const profileDir =
|
|
5719
|
+
const baseDir2 = configDirs2().find((dir) => existsSync4(dir)) ?? configDirs2()[0];
|
|
5720
|
+
const profileDir = join5(baseDir2, "profiles", profile);
|
|
5613
5721
|
mkdirSync2(profileDir, { recursive: true });
|
|
5614
|
-
writeFileSync2(
|
|
5722
|
+
writeFileSync2(join5(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
5615
5723
|
}
|
|
5616
5724
|
function configDirs2() {
|
|
5617
5725
|
const explicit = process.env.HASNA_GOOGLE_DRIVE_CONNECTOR_DIR ?? process.env.GOOGLE_DRIVE_CONNECTOR_DIR;
|
|
5618
5726
|
if (explicit)
|
|
5619
5727
|
return [explicit];
|
|
5620
|
-
const
|
|
5621
|
-
return [
|
|
5728
|
+
const baseDir2 = connectorsHome();
|
|
5729
|
+
return [join5(baseDir2, "googledrive"), join5(baseDir2, "connect-googledrive")];
|
|
5622
5730
|
}
|
|
5623
5731
|
function readJson2(path) {
|
|
5624
|
-
if (!
|
|
5732
|
+
if (!existsSync4(path))
|
|
5625
5733
|
return null;
|
|
5626
5734
|
try {
|
|
5627
5735
|
return JSON.parse(readFileSync2(path, "utf8"));
|
|
@@ -5655,6 +5763,7 @@ function extractGoogleError(body) {
|
|
|
5655
5763
|
}
|
|
5656
5764
|
var DRIVE_API_BASE = "https://www.googleapis.com/drive/v3", TOKEN_URL2 = "https://oauth2.googleapis.com/token", REFRESH_BUFFER_MS2, DEFAULT_FILE_FIELDS, DEFAULT_EXPORT_FORMATS, EXPORT_EXTENSIONS, listFilesSchema, listDrivesSchema, fileIdSchema, downloadSchema, profilesStatusSchema, googleDriveConnector;
|
|
5657
5765
|
var init_googledrive = __esm(() => {
|
|
5766
|
+
init_paths();
|
|
5658
5767
|
init_zod();
|
|
5659
5768
|
init_connector();
|
|
5660
5769
|
REFRESH_BUFFER_MS2 = 5 * 60 * 1000;
|
|
@@ -5804,7 +5913,7 @@ var package_default;
|
|
|
5804
5913
|
var init_package = __esm(() => {
|
|
5805
5914
|
package_default = {
|
|
5806
5915
|
name: "@hasna/connectors",
|
|
5807
|
-
version: "1.4.
|
|
5916
|
+
version: "1.4.5",
|
|
5808
5917
|
description: "Open source connector library - Install API connectors with a single command",
|
|
5809
5918
|
type: "module",
|
|
5810
5919
|
bin: {
|
|
@@ -5876,6 +5985,7 @@ var init_package = __esm(() => {
|
|
|
5876
5985
|
},
|
|
5877
5986
|
dependencies: {
|
|
5878
5987
|
"@hasna/events": "0.1.8",
|
|
5988
|
+
"@hasna/paths": "0.1.0",
|
|
5879
5989
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
5880
5990
|
chalk: "^5.3.0",
|
|
5881
5991
|
commander: "^12.1.0",
|
|
@@ -5976,33 +6086,32 @@ __export(exports_database, {
|
|
|
5976
6086
|
closeDatabase: () => closeDatabase,
|
|
5977
6087
|
SqliteAdapter: () => SqliteAdapter
|
|
5978
6088
|
});
|
|
5979
|
-
import { dirname as dirname2, join as
|
|
5980
|
-
import {
|
|
5981
|
-
import { mkdirSync as mkdirSync3, existsSync as existsSync4, readdirSync as readdirSync3, copyFileSync, statSync } from "fs";
|
|
6089
|
+
import { dirname as dirname2, join as join6 } from "path";
|
|
6090
|
+
import { mkdirSync as mkdirSync3, existsSync as existsSync5, readdirSync as readdirSync3, copyFileSync, statSync } from "fs";
|
|
5982
6091
|
function mergeDirectoryContents(sourceDir, targetDir) {
|
|
5983
|
-
if (!
|
|
6092
|
+
if (!existsSync5(sourceDir)) {
|
|
5984
6093
|
return;
|
|
5985
6094
|
}
|
|
5986
6095
|
mkdirSync3(targetDir, { recursive: true });
|
|
5987
6096
|
for (const entry of readdirSync3(sourceDir)) {
|
|
5988
|
-
const sourcePath =
|
|
5989
|
-
const targetPath =
|
|
6097
|
+
const sourcePath = join6(sourceDir, entry);
|
|
6098
|
+
const targetPath = join6(targetDir, entry);
|
|
5990
6099
|
try {
|
|
5991
6100
|
const sourceStat = statSync(sourcePath);
|
|
5992
6101
|
if (sourceStat.isDirectory()) {
|
|
5993
6102
|
mergeDirectoryContents(sourcePath, targetPath);
|
|
5994
6103
|
continue;
|
|
5995
6104
|
}
|
|
5996
|
-
if (!
|
|
6105
|
+
if (!existsSync5(targetPath)) {
|
|
5997
6106
|
copyFileSync(sourcePath, targetPath);
|
|
5998
6107
|
}
|
|
5999
6108
|
} catch {}
|
|
6000
6109
|
}
|
|
6001
6110
|
}
|
|
6002
6111
|
function getConnectorsHome() {
|
|
6003
|
-
const
|
|
6004
|
-
const
|
|
6005
|
-
const legacyDirs = [
|
|
6112
|
+
const newDir = connectorsHome();
|
|
6113
|
+
const home = effectiveHome();
|
|
6114
|
+
const legacyDirs = [join6(home, ".connectors"), join6(home, ".connect")];
|
|
6006
6115
|
mkdirSync3(newDir, { recursive: true });
|
|
6007
6116
|
for (const legacyDir of legacyDirs) {
|
|
6008
6117
|
try {
|
|
@@ -6150,13 +6259,14 @@ var DB_DIR, DB_PATH, _db = null, _dbPath = null;
|
|
|
6150
6259
|
var init_database = __esm(() => {
|
|
6151
6260
|
init_sqlite_adapter();
|
|
6152
6261
|
init_sqlite_adapter();
|
|
6262
|
+
init_paths();
|
|
6153
6263
|
DB_DIR = getConnectorsHome();
|
|
6154
|
-
DB_PATH =
|
|
6264
|
+
DB_PATH = join6(DB_DIR, "connectors.db");
|
|
6155
6265
|
});
|
|
6156
6266
|
|
|
6157
6267
|
// src/lib/connector-resolver.ts
|
|
6158
|
-
import { existsSync as
|
|
6159
|
-
import { join as
|
|
6268
|
+
import { existsSync as existsSync6, readdirSync as readdirSync4, statSync as statSync2 } from "fs";
|
|
6269
|
+
import { join as join7 } from "path";
|
|
6160
6270
|
function stripLegacyPrefix(name) {
|
|
6161
6271
|
return name.startsWith(LEGACY_CONNECTOR_PREFIX) ? name.slice(LEGACY_CONNECTOR_PREFIX.length) : name;
|
|
6162
6272
|
}
|
|
@@ -6199,8 +6309,8 @@ function connectorPackageDirNames(name) {
|
|
|
6199
6309
|
function resolveConnectorPackagePath(connectorsDir, name) {
|
|
6200
6310
|
const resolution = resolveConnectorName(name);
|
|
6201
6311
|
const dirNames = connectorPackageDirNames(name);
|
|
6202
|
-
const checkedPaths = dirNames.map((dirName) =>
|
|
6203
|
-
const existingPath = checkedPaths.find((path) =>
|
|
6312
|
+
const checkedPaths = dirNames.map((dirName) => join7(connectorsDir, dirName));
|
|
6313
|
+
const existingPath = checkedPaths.find((path) => existsSync6(path)) ?? null;
|
|
6204
6314
|
const existingDirName = existingPath ? dirNames[checkedPaths.indexOf(existingPath)] : null;
|
|
6205
6315
|
return {
|
|
6206
6316
|
...resolution,
|
|
@@ -6216,16 +6326,16 @@ function getConnectorPackagePath(connectorsDir, name) {
|
|
|
6216
6326
|
const resolved = resolveConnectorPackagePath(connectorsDir, name);
|
|
6217
6327
|
return resolved.existingPath ?? resolved.preferredPath;
|
|
6218
6328
|
}
|
|
6219
|
-
function resolveConnectorConfigPaths(name,
|
|
6329
|
+
function resolveConnectorConfigPaths(name, connectorsHome2 = getConnectorsHome()) {
|
|
6220
6330
|
const resolution = resolveConnectorName(name);
|
|
6221
6331
|
const preferredDirName = resolution.canonicalName || resolution.legacyName;
|
|
6222
|
-
const preferredPath =
|
|
6223
|
-
const legacyPath =
|
|
6332
|
+
const preferredPath = join7(connectorsHome2, preferredDirName);
|
|
6333
|
+
const legacyPath = join7(connectorsHome2, resolution.legacyName);
|
|
6224
6334
|
const paths = preferredPath === legacyPath ? [preferredPath] : [preferredPath, legacyPath];
|
|
6225
|
-
const existingPaths = paths.filter((path) =>
|
|
6335
|
+
const existingPaths = paths.filter((path) => existsSync6(path));
|
|
6226
6336
|
return {
|
|
6227
6337
|
...resolution,
|
|
6228
|
-
connectorsHome,
|
|
6338
|
+
connectorsHome: connectorsHome2,
|
|
6229
6339
|
preferredDirName,
|
|
6230
6340
|
preferredPath,
|
|
6231
6341
|
legacyPath,
|
|
@@ -6233,11 +6343,11 @@ function resolveConnectorConfigPaths(name, connectorsHome = getConnectorsHome())
|
|
|
6233
6343
|
readPaths: paths
|
|
6234
6344
|
};
|
|
6235
6345
|
}
|
|
6236
|
-
function getConnectorConfigDir(name,
|
|
6237
|
-
return resolveConnectorConfigPaths(name,
|
|
6346
|
+
function getConnectorConfigDir(name, connectorsHome2 = getConnectorsHome()) {
|
|
6347
|
+
return resolveConnectorConfigPaths(name, connectorsHome2).preferredPath;
|
|
6238
6348
|
}
|
|
6239
|
-
function getConnectorConfigReadDirs(name,
|
|
6240
|
-
return resolveConnectorConfigPaths(name,
|
|
6349
|
+
function getConnectorConfigReadDirs(name, connectorsHome2 = getConnectorsHome()) {
|
|
6350
|
+
return resolveConnectorConfigPaths(name, connectorsHome2).readPaths;
|
|
6241
6351
|
}
|
|
6242
6352
|
var LEGACY_CONNECTOR_PREFIX = "connect-", CONNECTOR_SLUG_ALIASES, CONNECTOR_NAME_RE2;
|
|
6243
6353
|
var init_connector_resolver = __esm(() => {
|
|
@@ -6251,7 +6361,7 @@ var init_connector_resolver = __esm(() => {
|
|
|
6251
6361
|
|
|
6252
6362
|
// src/core/connectors/imessage.ts
|
|
6253
6363
|
import {
|
|
6254
|
-
existsSync as
|
|
6364
|
+
existsSync as existsSync7,
|
|
6255
6365
|
mkdirSync as mkdirSync4,
|
|
6256
6366
|
readFileSync as readFileSync3,
|
|
6257
6367
|
readdirSync as readdirSync5,
|
|
@@ -6259,7 +6369,7 @@ import {
|
|
|
6259
6369
|
statSync as statSync3,
|
|
6260
6370
|
writeFileSync as writeFileSync3
|
|
6261
6371
|
} from "fs";
|
|
6262
|
-
import { join as
|
|
6372
|
+
import { join as join8 } from "path";
|
|
6263
6373
|
function buildRootHelp(specs) {
|
|
6264
6374
|
const lines = [
|
|
6265
6375
|
"Usage: connect-imessage [options] [command]",
|
|
@@ -6310,12 +6420,12 @@ function getConfigReadDirs() {
|
|
|
6310
6420
|
return getConnectorConfigReadDirs(CONNECTOR_NAME);
|
|
6311
6421
|
}
|
|
6312
6422
|
function getProfilesDir() {
|
|
6313
|
-
return
|
|
6423
|
+
return join8(getConfigDir(), "profiles");
|
|
6314
6424
|
}
|
|
6315
6425
|
function getCurrentProfile() {
|
|
6316
6426
|
for (const configDir of getConfigReadDirs()) {
|
|
6317
|
-
const currentProfileFile =
|
|
6318
|
-
if (!
|
|
6427
|
+
const currentProfileFile = join8(configDir, "current_profile");
|
|
6428
|
+
if (!existsSync7(currentProfileFile))
|
|
6319
6429
|
continue;
|
|
6320
6430
|
try {
|
|
6321
6431
|
return readFileSync3(currentProfileFile, "utf-8").trim() || "default";
|
|
@@ -6328,16 +6438,16 @@ function getCurrentProfile() {
|
|
|
6328
6438
|
function setCurrentProfile(profile) {
|
|
6329
6439
|
const configDir = getConfigDir();
|
|
6330
6440
|
mkdirSync4(configDir, { recursive: true });
|
|
6331
|
-
writeFileSync3(
|
|
6441
|
+
writeFileSync3(join8(configDir, "current_profile"), profile);
|
|
6332
6442
|
}
|
|
6333
6443
|
function getFlatProfilePath(profile) {
|
|
6334
|
-
return
|
|
6444
|
+
return join8(getProfilesDir(), `${profile}.json`);
|
|
6335
6445
|
}
|
|
6336
6446
|
function getFlatProfileReadPaths(profile) {
|
|
6337
|
-
return getConfigReadDirs().map((dir) =>
|
|
6447
|
+
return getConfigReadDirs().map((dir) => join8(dir, "profiles", `${profile}.json`));
|
|
6338
6448
|
}
|
|
6339
6449
|
function getDirectoryProfileReadPaths(profile) {
|
|
6340
|
-
return getConfigReadDirs().map((dir) =>
|
|
6450
|
+
return getConfigReadDirs().map((dir) => join8(dir, "profiles", profile, "config.json"));
|
|
6341
6451
|
}
|
|
6342
6452
|
function loadJsonFile(path) {
|
|
6343
6453
|
try {
|
|
@@ -6357,8 +6467,8 @@ function sanitizeProfileConfig(config2) {
|
|
|
6357
6467
|
};
|
|
6358
6468
|
}
|
|
6359
6469
|
function loadProfile(profile = getCurrentProfile()) {
|
|
6360
|
-
const flatConfig = getFlatProfileReadPaths(profile).reverse().reduce((config2, path) => ({ ...config2, ...
|
|
6361
|
-
const directoryConfig = getDirectoryProfileReadPaths(profile).reverse().reduce((config2, path) => ({ ...config2, ...
|
|
6470
|
+
const flatConfig = getFlatProfileReadPaths(profile).reverse().reduce((config2, path) => ({ ...config2, ...existsSync7(path) ? loadJsonFile(path) : {} }), {});
|
|
6471
|
+
const directoryConfig = getDirectoryProfileReadPaths(profile).reverse().reduce((config2, path) => ({ ...config2, ...existsSync7(path) ? loadJsonFile(path) : {} }), {});
|
|
6362
6472
|
return sanitizeProfileConfig({
|
|
6363
6473
|
...flatConfig,
|
|
6364
6474
|
...directoryConfig
|
|
@@ -6374,17 +6484,17 @@ function profileExists(profile) {
|
|
|
6374
6484
|
if (profile === "default") {
|
|
6375
6485
|
return true;
|
|
6376
6486
|
}
|
|
6377
|
-
return getFlatProfileReadPaths(profile).some((path) =>
|
|
6487
|
+
return getFlatProfileReadPaths(profile).some((path) => existsSync7(path)) || getConfigReadDirs().some((dir) => existsSync7(join8(dir, "profiles", profile)));
|
|
6378
6488
|
}
|
|
6379
6489
|
function listProfiles3() {
|
|
6380
6490
|
const seen = new Set(["default"]);
|
|
6381
6491
|
for (const configDir of getConfigReadDirs()) {
|
|
6382
|
-
const profilesDir =
|
|
6383
|
-
if (!
|
|
6492
|
+
const profilesDir = join8(configDir, "profiles");
|
|
6493
|
+
if (!existsSync7(profilesDir))
|
|
6384
6494
|
continue;
|
|
6385
6495
|
try {
|
|
6386
6496
|
for (const entry of readdirSync5(profilesDir)) {
|
|
6387
|
-
const fullPath =
|
|
6497
|
+
const fullPath = join8(profilesDir, entry);
|
|
6388
6498
|
const stat = statSync3(fullPath);
|
|
6389
6499
|
if (stat.isDirectory()) {
|
|
6390
6500
|
seen.add(entry);
|
|
@@ -6406,11 +6516,11 @@ function createProfile(profile, config2 = {}) {
|
|
|
6406
6516
|
}
|
|
6407
6517
|
function clearProfile(profile = getCurrentProfile()) {
|
|
6408
6518
|
const flatPath = getFlatProfilePath(profile);
|
|
6409
|
-
const directoryPath =
|
|
6410
|
-
if (
|
|
6519
|
+
const directoryPath = join8(getProfilesDir(), profile);
|
|
6520
|
+
if (existsSync7(flatPath)) {
|
|
6411
6521
|
rmSync(flatPath);
|
|
6412
6522
|
}
|
|
6413
|
-
if (
|
|
6523
|
+
if (existsSync7(directoryPath)) {
|
|
6414
6524
|
rmSync(directoryPath, { recursive: true, force: true });
|
|
6415
6525
|
}
|
|
6416
6526
|
}
|
|
@@ -7336,18 +7446,18 @@ var init_imessage = __esm(() => {
|
|
|
7336
7446
|
});
|
|
7337
7447
|
|
|
7338
7448
|
// src/core/connectors/stripe.ts
|
|
7339
|
-
import { existsSync as
|
|
7340
|
-
import { dirname as dirname3, join as
|
|
7449
|
+
import { existsSync as existsSync8 } from "fs";
|
|
7450
|
+
import { dirname as dirname3, join as join9 } from "path";
|
|
7341
7451
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
|
|
7342
7452
|
function resolveStripeConnectorDir() {
|
|
7343
7453
|
const candidates = [
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7454
|
+
join9(__dirname3, "..", "..", "..", "connectors", "stripe"),
|
|
7455
|
+
join9(__dirname3, "..", "..", "connectors", "stripe"),
|
|
7456
|
+
join9(__dirname3, "..", "connectors", "stripe"),
|
|
7457
|
+
join9(process.cwd(), "connectors", "stripe")
|
|
7348
7458
|
];
|
|
7349
7459
|
for (const candidate of candidates) {
|
|
7350
|
-
if (
|
|
7460
|
+
if (existsSync8(candidate)) {
|
|
7351
7461
|
return candidate;
|
|
7352
7462
|
}
|
|
7353
7463
|
}
|
|
@@ -7395,10 +7505,10 @@ function buildCommandHelp2(spec) {
|
|
|
7395
7505
|
`);
|
|
7396
7506
|
}
|
|
7397
7507
|
async function loadStripeApiModule() {
|
|
7398
|
-
return await import(pathToFileURL2(
|
|
7508
|
+
return await import(pathToFileURL2(join9(CONNECTOR_DIR2, "src", "api", "index.ts")).href);
|
|
7399
7509
|
}
|
|
7400
7510
|
async function loadStripeConfigModule() {
|
|
7401
|
-
return await import(pathToFileURL2(
|
|
7511
|
+
return await import(pathToFileURL2(join9(CONNECTOR_DIR2, "src", "utils", "config.ts")).href);
|
|
7402
7512
|
}
|
|
7403
7513
|
function extractGlobalArgs3(args) {
|
|
7404
7514
|
const remaining = [];
|
|
@@ -11119,7 +11229,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
11119
11229
|
const schOrFunc = root.refs[ref];
|
|
11120
11230
|
if (schOrFunc)
|
|
11121
11231
|
return schOrFunc;
|
|
11122
|
-
let _sch =
|
|
11232
|
+
let _sch = resolve2.call(this, root, ref);
|
|
11123
11233
|
if (_sch === undefined) {
|
|
11124
11234
|
const schema = (_a = root.localRefs) === null || _a === undefined ? undefined : _a[ref];
|
|
11125
11235
|
const { schemaId } = this.opts;
|
|
@@ -11146,7 +11256,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
11146
11256
|
function sameSchemaEnv(s1, s2) {
|
|
11147
11257
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
11148
11258
|
}
|
|
11149
|
-
function
|
|
11259
|
+
function resolve2(root, ref) {
|
|
11150
11260
|
let sch;
|
|
11151
11261
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
11152
11262
|
ref = sch;
|
|
@@ -11732,7 +11842,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
11732
11842
|
}
|
|
11733
11843
|
return uri;
|
|
11734
11844
|
}
|
|
11735
|
-
function
|
|
11845
|
+
function resolve2(baseURI, relativeURI, options) {
|
|
11736
11846
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
11737
11847
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
|
|
11738
11848
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -12017,7 +12127,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
12017
12127
|
var fastUri = {
|
|
12018
12128
|
SCHEMES,
|
|
12019
12129
|
normalize,
|
|
12020
|
-
resolve,
|
|
12130
|
+
resolve: resolve2,
|
|
12021
12131
|
resolveComponent,
|
|
12022
12132
|
equal,
|
|
12023
12133
|
serialize,
|
|
@@ -14829,14 +14939,14 @@ __export(exports_llm, {
|
|
|
14829
14939
|
PROVIDER_DEFAULTS: () => PROVIDER_DEFAULTS,
|
|
14830
14940
|
LLMClient: () => LLMClient
|
|
14831
14941
|
});
|
|
14832
|
-
import { existsSync as
|
|
14833
|
-
import { join as
|
|
14942
|
+
import { existsSync as existsSync10, readFileSync as readFileSync5, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5 } from "fs";
|
|
14943
|
+
import { join as join11 } from "path";
|
|
14834
14944
|
function getLlmConfigPath() {
|
|
14835
|
-
return
|
|
14945
|
+
return join11(getConnectorsHome(), "llm.json");
|
|
14836
14946
|
}
|
|
14837
14947
|
function getLlmConfig() {
|
|
14838
14948
|
const path = getLlmConfigPath();
|
|
14839
|
-
if (!
|
|
14949
|
+
if (!existsSync10(path))
|
|
14840
14950
|
return null;
|
|
14841
14951
|
try {
|
|
14842
14952
|
return JSON.parse(readFileSync5(path, "utf-8"));
|
|
@@ -14966,30 +15076,30 @@ __export(exports_installer, {
|
|
|
14966
15076
|
getConnectorDocs: () => getConnectorDocs,
|
|
14967
15077
|
connectorExists: () => connectorExists
|
|
14968
15078
|
});
|
|
14969
|
-
import { existsSync as
|
|
14970
|
-
import { join as
|
|
15079
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync5, readdirSync as readdirSync6, statSync as statSync4, rmSync as rmSync2 } from "fs";
|
|
15080
|
+
import { join as join12, dirname as dirname5 } from "path";
|
|
14971
15081
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
14972
15082
|
function resolveConnectorsDir() {
|
|
14973
|
-
const fromBin =
|
|
14974
|
-
if (
|
|
15083
|
+
const fromBin = join12(__dirname4, "..", "connectors");
|
|
15084
|
+
if (existsSync11(fromBin))
|
|
14975
15085
|
return fromBin;
|
|
14976
|
-
const fromSrc =
|
|
14977
|
-
if (
|
|
15086
|
+
const fromSrc = join12(__dirname4, "..", "..", "connectors");
|
|
15087
|
+
if (existsSync11(fromSrc))
|
|
14978
15088
|
return fromSrc;
|
|
14979
15089
|
return fromBin;
|
|
14980
15090
|
}
|
|
14981
15091
|
function getProjectConnectorsDir(targetDir) {
|
|
14982
|
-
return
|
|
15092
|
+
return join12(targetDir, PROJECT_CONNECTORS_DIRNAME);
|
|
14983
15093
|
}
|
|
14984
15094
|
function getEnablementManifestPath(targetDir) {
|
|
14985
|
-
return
|
|
15095
|
+
return join12(getProjectConnectorsDir(targetDir), ENABLEMENT_MANIFEST_FILENAME);
|
|
14986
15096
|
}
|
|
14987
15097
|
function getLegacyInstallPath(targetDir, name) {
|
|
14988
|
-
return
|
|
15098
|
+
return join12(getProjectConnectorsDir(targetDir), legacyConnectorName(name));
|
|
14989
15099
|
}
|
|
14990
15100
|
function loadEnablementManifest(targetDir) {
|
|
14991
15101
|
const manifestPath = getEnablementManifestPath(targetDir);
|
|
14992
|
-
if (!
|
|
15102
|
+
if (!existsSync11(manifestPath)) {
|
|
14993
15103
|
return null;
|
|
14994
15104
|
}
|
|
14995
15105
|
try {
|
|
@@ -15009,11 +15119,11 @@ function loadEnablementManifest(targetDir) {
|
|
|
15009
15119
|
}
|
|
15010
15120
|
function getLegacyInstalledConnectors(targetDir) {
|
|
15011
15121
|
const connectorsDir = getProjectConnectorsDir(targetDir);
|
|
15012
|
-
if (!
|
|
15122
|
+
if (!existsSync11(connectorsDir)) {
|
|
15013
15123
|
return [];
|
|
15014
15124
|
}
|
|
15015
15125
|
return readdirSync6(connectorsDir).filter((entry) => {
|
|
15016
|
-
const fullPath =
|
|
15126
|
+
const fullPath = join12(connectorsDir, entry);
|
|
15017
15127
|
return entry.startsWith("connect-") && statSync4(fullPath).isDirectory();
|
|
15018
15128
|
}).map((entry) => entry.replace("connect-", "")).sort();
|
|
15019
15129
|
}
|
|
@@ -15022,7 +15132,7 @@ function getEnabledConnectors(targetDir) {
|
|
|
15022
15132
|
return [...new Set([...manifestConnectors, ...getLegacyInstalledConnectors(targetDir)])].sort();
|
|
15023
15133
|
}
|
|
15024
15134
|
function updateConnectorsIndex(connectorsDir, connectors18) {
|
|
15025
|
-
const indexPath =
|
|
15135
|
+
const indexPath = join12(connectorsDir, ENABLEMENT_INDEX_FILENAME);
|
|
15026
15136
|
const connectorList = connectors18.map((connector) => ` "${connector}",`).join(`
|
|
15027
15137
|
`);
|
|
15028
15138
|
const content = `/**
|
|
@@ -15058,7 +15168,7 @@ function getConnectorPath(name) {
|
|
|
15058
15168
|
}
|
|
15059
15169
|
function connectorExists(name) {
|
|
15060
15170
|
const normalizedName = normalizeConnectorName(name);
|
|
15061
|
-
return hasInternalConnectorDefinition(normalizedName) ||
|
|
15171
|
+
return hasInternalConnectorDefinition(normalizedName) || existsSync11(getConnectorPath(normalizedName));
|
|
15062
15172
|
}
|
|
15063
15173
|
function installConnector(name, options = {}) {
|
|
15064
15174
|
const { targetDir = process.cwd(), overwrite = false } = options;
|
|
@@ -15091,7 +15201,7 @@ function installConnector(name, options = {}) {
|
|
|
15091
15201
|
try {
|
|
15092
15202
|
const nextEnabled = [...new Set([...installed, normalizedName])].sort();
|
|
15093
15203
|
writeEnablementManifest(targetDir, nextEnabled);
|
|
15094
|
-
if (overwrite &&
|
|
15204
|
+
if (overwrite && existsSync11(legacyInstallPath)) {
|
|
15095
15205
|
rmSync2(legacyInstallPath, { recursive: true });
|
|
15096
15206
|
}
|
|
15097
15207
|
return {
|
|
@@ -15126,8 +15236,8 @@ function parseConnectorDocs(raw) {
|
|
|
15126
15236
|
function getConnectorDocs(name) {
|
|
15127
15237
|
const normalizedName = normalizeConnectorName(name);
|
|
15128
15238
|
const connectorPath = getConnectorPath(normalizedName);
|
|
15129
|
-
const claudeMdPath =
|
|
15130
|
-
if (
|
|
15239
|
+
const claudeMdPath = join12(connectorPath, "CLAUDE.md");
|
|
15240
|
+
if (existsSync11(claudeMdPath)) {
|
|
15131
15241
|
return parseConnectorDocs(readFileSync6(claudeMdPath, "utf-8"));
|
|
15132
15242
|
}
|
|
15133
15243
|
const internalDocs = getInternalConnectorDefinition(normalizedName)?.docsMarkdown;
|
|
@@ -15172,7 +15282,7 @@ function removeConnector(name, targetDir = process.cwd()) {
|
|
|
15172
15282
|
const nextEnabled = installed.filter((connector) => connector !== normalizedName);
|
|
15173
15283
|
writeEnablementManifest(targetDir, nextEnabled);
|
|
15174
15284
|
const legacyInstallPath = getLegacyInstallPath(targetDir, normalizedName);
|
|
15175
|
-
if (
|
|
15285
|
+
if (existsSync11(legacyInstallPath)) {
|
|
15176
15286
|
rmSync2(legacyInstallPath, { recursive: true });
|
|
15177
15287
|
}
|
|
15178
15288
|
return true;
|
|
@@ -15255,7 +15365,7 @@ var init_usage = __esm(() => {
|
|
|
15255
15365
|
});
|
|
15256
15366
|
|
|
15257
15367
|
// src/lib/lock.ts
|
|
15258
|
-
import { openSync, closeSync, unlinkSync, existsSync as
|
|
15368
|
+
import { openSync, closeSync, unlinkSync, existsSync as existsSync12, statSync as statSync5 } from "fs";
|
|
15259
15369
|
import { mkdirSync as mkdirSync7 } from "fs";
|
|
15260
15370
|
function lockPath(connector) {
|
|
15261
15371
|
const dir = getConnectorConfigDir(connector);
|
|
@@ -15271,7 +15381,7 @@ function isStale(path) {
|
|
|
15271
15381
|
}
|
|
15272
15382
|
}
|
|
15273
15383
|
function tryAcquire(path) {
|
|
15274
|
-
if (
|
|
15384
|
+
if (existsSync12(path) && isStale(path)) {
|
|
15275
15385
|
try {
|
|
15276
15386
|
unlinkSync(path);
|
|
15277
15387
|
} catch {}
|
|
@@ -15303,7 +15413,7 @@ async function withWriteLock(connector, fn) {
|
|
|
15303
15413
|
release(path);
|
|
15304
15414
|
}
|
|
15305
15415
|
}
|
|
15306
|
-
await new Promise((
|
|
15416
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MS));
|
|
15307
15417
|
}
|
|
15308
15418
|
throw new LockTimeoutError(connector);
|
|
15309
15419
|
}
|
|
@@ -15321,8 +15431,8 @@ var init_lock = __esm(() => {
|
|
|
15321
15431
|
});
|
|
15322
15432
|
|
|
15323
15433
|
// src/server/auth.ts
|
|
15324
|
-
import { chmodSync, existsSync as
|
|
15325
|
-
import { join as
|
|
15434
|
+
import { chmodSync, existsSync as existsSync13, readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync8, readdirSync as readdirSync7, rmSync as rmSync3, statSync as statSync6 } from "fs";
|
|
15435
|
+
import { join as join13 } from "path";
|
|
15326
15436
|
function getAuthType(name) {
|
|
15327
15437
|
name = normalizeConnectorName(name);
|
|
15328
15438
|
const docs = getConnectorDocs(name);
|
|
@@ -15359,8 +15469,8 @@ function writePrivateJson(path, data) {
|
|
|
15359
15469
|
function getCurrentProfile2(name) {
|
|
15360
15470
|
name = normalizeConnectorName(name);
|
|
15361
15471
|
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
15362
|
-
const currentProfileFile =
|
|
15363
|
-
if (
|
|
15472
|
+
const currentProfileFile = join13(configDir, "current_profile");
|
|
15473
|
+
if (existsSync13(currentProfileFile)) {
|
|
15364
15474
|
try {
|
|
15365
15475
|
return readFileSync7(currentProfileFile, "utf-8").trim() || "default";
|
|
15366
15476
|
} catch {
|
|
@@ -15373,14 +15483,14 @@ function getCurrentProfile2(name) {
|
|
|
15373
15483
|
function loadProfileConfigFromDir(configDir, profile) {
|
|
15374
15484
|
let flatConfig = {};
|
|
15375
15485
|
let dirConfig = {};
|
|
15376
|
-
const profileFile =
|
|
15377
|
-
if (
|
|
15486
|
+
const profileFile = join13(configDir, "profiles", `${profile}.json`);
|
|
15487
|
+
if (existsSync13(profileFile)) {
|
|
15378
15488
|
try {
|
|
15379
15489
|
flatConfig = JSON.parse(readFileSync7(profileFile, "utf-8"));
|
|
15380
15490
|
} catch {}
|
|
15381
15491
|
}
|
|
15382
|
-
const profileDirConfig =
|
|
15383
|
-
if (
|
|
15492
|
+
const profileDirConfig = join13(configDir, "profiles", profile, "config.json");
|
|
15493
|
+
if (existsSync13(profileDirConfig)) {
|
|
15384
15494
|
try {
|
|
15385
15495
|
dirConfig = JSON.parse(readFileSync7(profileDirConfig, "utf-8"));
|
|
15386
15496
|
} catch {}
|
|
@@ -15400,8 +15510,8 @@ function loadTokens3(name) {
|
|
|
15400
15510
|
name = normalizeConnectorName(name);
|
|
15401
15511
|
const profile = getCurrentProfile2(name);
|
|
15402
15512
|
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
15403
|
-
const tokensFile =
|
|
15404
|
-
if (
|
|
15513
|
+
const tokensFile = join13(configDir, "profiles", profile, "tokens.json");
|
|
15514
|
+
if (existsSync13(tokensFile)) {
|
|
15405
15515
|
try {
|
|
15406
15516
|
return JSON.parse(readFileSync7(tokensFile, "utf-8"));
|
|
15407
15517
|
} catch {
|
|
@@ -15534,10 +15644,10 @@ function _saveApiKey(name, key, field) {
|
|
|
15534
15644
|
const profile = getCurrentProfile2(name);
|
|
15535
15645
|
const keyField = field || guessKeyField(name);
|
|
15536
15646
|
if (keyField === "clientId" || keyField === "clientSecret") {
|
|
15537
|
-
const credentialsFile =
|
|
15647
|
+
const credentialsFile = join13(configDir, "credentials.json");
|
|
15538
15648
|
ensurePrivateDir(configDir);
|
|
15539
15649
|
let creds = {};
|
|
15540
|
-
if (
|
|
15650
|
+
if (existsSync13(credentialsFile)) {
|
|
15541
15651
|
try {
|
|
15542
15652
|
creds = JSON.parse(readFileSync7(credentialsFile, "utf-8"));
|
|
15543
15653
|
} catch {}
|
|
@@ -15546,10 +15656,10 @@ function _saveApiKey(name, key, field) {
|
|
|
15546
15656
|
writePrivateJson(credentialsFile, creds);
|
|
15547
15657
|
return;
|
|
15548
15658
|
}
|
|
15549
|
-
const profilesDir =
|
|
15550
|
-
const profileFile =
|
|
15551
|
-
const profileDir =
|
|
15552
|
-
if (
|
|
15659
|
+
const profilesDir = join13(configDir, "profiles");
|
|
15660
|
+
const profileFile = join13(profilesDir, `${profile}.json`);
|
|
15661
|
+
const profileDir = join13(profilesDir, profile);
|
|
15662
|
+
if (existsSync13(profileFile)) {
|
|
15553
15663
|
let config2 = {};
|
|
15554
15664
|
try {
|
|
15555
15665
|
config2 = JSON.parse(readFileSync7(profileFile, "utf-8"));
|
|
@@ -15560,10 +15670,10 @@ function _saveApiKey(name, key, field) {
|
|
|
15560
15670
|
writePrivateJson(profileFile, config2);
|
|
15561
15671
|
return;
|
|
15562
15672
|
}
|
|
15563
|
-
if (
|
|
15564
|
-
const configFile =
|
|
15673
|
+
if (existsSync13(profileDir)) {
|
|
15674
|
+
const configFile = join13(profileDir, "config.json");
|
|
15565
15675
|
let config2 = {};
|
|
15566
|
-
if (
|
|
15676
|
+
if (existsSync13(configFile)) {
|
|
15567
15677
|
try {
|
|
15568
15678
|
config2 = JSON.parse(readFileSync7(configFile, "utf-8"));
|
|
15569
15679
|
} catch {}
|
|
@@ -15578,7 +15688,7 @@ function _saveApiKey(name, key, field) {
|
|
|
15578
15688
|
ensurePrivateDir(configDir);
|
|
15579
15689
|
ensurePrivateDir(profilesDir);
|
|
15580
15690
|
ensurePrivateDir(profileDir);
|
|
15581
|
-
writePrivateJson(
|
|
15691
|
+
writePrivateJson(join13(profileDir, "config.json"), { [keyField]: key });
|
|
15582
15692
|
}
|
|
15583
15693
|
function guessKeyField(name) {
|
|
15584
15694
|
name = normalizeConnectorName(name);
|
|
@@ -15600,8 +15710,8 @@ function guessKeyField(name) {
|
|
|
15600
15710
|
function getOAuthConfig(name) {
|
|
15601
15711
|
name = normalizeConnectorName(name);
|
|
15602
15712
|
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
15603
|
-
const credentialsFile =
|
|
15604
|
-
if (
|
|
15713
|
+
const credentialsFile = join13(configDir, "credentials.json");
|
|
15714
|
+
if (existsSync13(credentialsFile)) {
|
|
15605
15715
|
try {
|
|
15606
15716
|
const creds = JSON.parse(readFileSync7(credentialsFile, "utf-8"));
|
|
15607
15717
|
return { clientId: creds.clientId, clientSecret: creds.clientSecret };
|
|
@@ -15618,12 +15728,12 @@ function saveOAuthTokens(name, tokens) {
|
|
|
15618
15728
|
name = normalizeConnectorName(name);
|
|
15619
15729
|
const configDir = getConnectorConfigDir2(name);
|
|
15620
15730
|
const profile = getCurrentProfile2(name);
|
|
15621
|
-
const profilesDir =
|
|
15622
|
-
const profileDir =
|
|
15731
|
+
const profilesDir = join13(configDir, "profiles");
|
|
15732
|
+
const profileDir = join13(profilesDir, profile);
|
|
15623
15733
|
ensurePrivateDir(configDir);
|
|
15624
15734
|
ensurePrivateDir(profilesDir);
|
|
15625
15735
|
ensurePrivateDir(profileDir);
|
|
15626
|
-
const tokensFile =
|
|
15736
|
+
const tokensFile = join13(profileDir, "tokens.json");
|
|
15627
15737
|
writePrivateJson(tokensFile, tokens);
|
|
15628
15738
|
}
|
|
15629
15739
|
async function refreshOAuthToken(name) {
|
|
@@ -15731,16 +15841,16 @@ __export(exports_runner, {
|
|
|
15731
15841
|
buildEnvWithCredentials: () => buildEnvWithCredentials,
|
|
15732
15842
|
buildConnectorOperationArgs: () => buildConnectorOperationArgs
|
|
15733
15843
|
});
|
|
15734
|
-
import { existsSync as
|
|
15735
|
-
import { join as
|
|
15844
|
+
import { existsSync as existsSync15, readdirSync as readdirSync8 } from "fs";
|
|
15845
|
+
import { join as join15, dirname as dirname6 } from "path";
|
|
15736
15846
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
15737
15847
|
import { spawn as spawn2 } from "child_process";
|
|
15738
15848
|
function resolveConnectorsDir2() {
|
|
15739
|
-
const fromBin =
|
|
15740
|
-
if (
|
|
15849
|
+
const fromBin = join15(__dirname5, "..", "connectors");
|
|
15850
|
+
if (existsSync15(fromBin))
|
|
15741
15851
|
return fromBin;
|
|
15742
|
-
const fromSrc =
|
|
15743
|
-
if (
|
|
15852
|
+
const fromSrc = join15(__dirname5, "..", "..", "connectors");
|
|
15853
|
+
if (existsSync15(fromSrc))
|
|
15744
15854
|
return fromSrc;
|
|
15745
15855
|
return fromBin;
|
|
15746
15856
|
}
|
|
@@ -15808,8 +15918,8 @@ function buildEnvWithCredentials(connectorName, baseEnv) {
|
|
|
15808
15918
|
function getConnectorCliPath(name) {
|
|
15809
15919
|
const safeName = normalizeConnectorName(name).replace(/[^a-z0-9-]/g, "");
|
|
15810
15920
|
const connectorDir = getConnectorPackagePath(CONNECTORS_DIR2, safeName);
|
|
15811
|
-
const cliPath =
|
|
15812
|
-
if (
|
|
15921
|
+
const cliPath = join15(connectorDir, "src", "cli", "index.ts");
|
|
15922
|
+
if (existsSync15(cliPath))
|
|
15813
15923
|
return cliPath;
|
|
15814
15924
|
return null;
|
|
15815
15925
|
}
|
|
@@ -16003,7 +16113,7 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
|
16003
16113
|
success: false
|
|
16004
16114
|
});
|
|
16005
16115
|
}
|
|
16006
|
-
return new Promise((
|
|
16116
|
+
return new Promise((resolve2) => {
|
|
16007
16117
|
const proc = spawn2("bun", ["run", cliPath, ...args], {
|
|
16008
16118
|
timeout: timeoutMs,
|
|
16009
16119
|
env: buildEnvWithCredentials(connectorName, process.env),
|
|
@@ -16018,7 +16128,7 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
|
16018
16128
|
stderr += data.toString();
|
|
16019
16129
|
});
|
|
16020
16130
|
proc.on("close", (code) => {
|
|
16021
|
-
|
|
16131
|
+
resolve2({
|
|
16022
16132
|
stdout: stdout.trim(),
|
|
16023
16133
|
stderr: stderr.trim(),
|
|
16024
16134
|
exitCode: code ?? 1,
|
|
@@ -16026,7 +16136,7 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
|
16026
16136
|
});
|
|
16027
16137
|
});
|
|
16028
16138
|
proc.on("error", (err) => {
|
|
16029
|
-
|
|
16139
|
+
resolve2({
|
|
16030
16140
|
stdout: "",
|
|
16031
16141
|
stderr: err.message,
|
|
16032
16142
|
exitCode: 1,
|
|
@@ -21635,8 +21745,8 @@ class StdioServerTransport {
|
|
|
21635
21745
|
|
|
21636
21746
|
// src/lib/registry.ts
|
|
21637
21747
|
init_builtins();
|
|
21638
|
-
import { existsSync as
|
|
21639
|
-
import { join as
|
|
21748
|
+
import { existsSync as existsSync9, readFileSync as readFileSync4 } from "fs";
|
|
21749
|
+
import { join as join10, dirname as dirname4 } from "path";
|
|
21640
21750
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
21641
21751
|
|
|
21642
21752
|
// src/lib/fuzzy.ts
|
|
@@ -30069,16 +30179,16 @@ function loadConnectorVersions() {
|
|
|
30069
30179
|
versionsLoaded = true;
|
|
30070
30180
|
const thisDir = dirname4(fileURLToPath3(import.meta.url));
|
|
30071
30181
|
const candidates = [
|
|
30072
|
-
|
|
30073
|
-
|
|
30182
|
+
join10(thisDir, "..", "connectors"),
|
|
30183
|
+
join10(thisDir, "..", "..", "connectors")
|
|
30074
30184
|
];
|
|
30075
|
-
const connectorsDir = candidates.find((d) =>
|
|
30185
|
+
const connectorsDir = candidates.find((d) => existsSync9(d));
|
|
30076
30186
|
if (!connectorsDir)
|
|
30077
30187
|
return;
|
|
30078
30188
|
for (const connector of CONNECTORS) {
|
|
30079
30189
|
try {
|
|
30080
|
-
const pkgPath =
|
|
30081
|
-
if (
|
|
30190
|
+
const pkgPath = join10(getConnectorPackagePath(connectorsDir, connector.name), "package.json");
|
|
30191
|
+
if (existsSync9(pkgPath)) {
|
|
30082
30192
|
const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|
|
30083
30193
|
connector.version = pkg.version || "0.0.0";
|
|
30084
30194
|
continue;
|
|
@@ -32041,7 +32151,7 @@ class Protocol {
|
|
|
32041
32151
|
return;
|
|
32042
32152
|
}
|
|
32043
32153
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1000;
|
|
32044
|
-
await new Promise((
|
|
32154
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
32045
32155
|
options?.signal?.throwIfAborted();
|
|
32046
32156
|
}
|
|
32047
32157
|
} catch (error2) {
|
|
@@ -32053,7 +32163,7 @@ class Protocol {
|
|
|
32053
32163
|
}
|
|
32054
32164
|
request(request2, resultSchema, options) {
|
|
32055
32165
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
32056
|
-
return new Promise((
|
|
32166
|
+
return new Promise((resolve2, reject) => {
|
|
32057
32167
|
const earlyReject = (error2) => {
|
|
32058
32168
|
reject(error2);
|
|
32059
32169
|
};
|
|
@@ -32131,7 +32241,7 @@ class Protocol {
|
|
|
32131
32241
|
if (!parseResult.success) {
|
|
32132
32242
|
reject(parseResult.error);
|
|
32133
32243
|
} else {
|
|
32134
|
-
|
|
32244
|
+
resolve2(parseResult.data);
|
|
32135
32245
|
}
|
|
32136
32246
|
} catch (error2) {
|
|
32137
32247
|
reject(error2);
|
|
@@ -32322,12 +32432,12 @@ class Protocol {
|
|
|
32322
32432
|
interval = task.pollInterval;
|
|
32323
32433
|
}
|
|
32324
32434
|
} catch {}
|
|
32325
|
-
return new Promise((
|
|
32435
|
+
return new Promise((resolve2, reject) => {
|
|
32326
32436
|
if (signal.aborted) {
|
|
32327
32437
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
32328
32438
|
return;
|
|
32329
32439
|
}
|
|
32330
|
-
const timeoutId = setTimeout(
|
|
32440
|
+
const timeoutId = setTimeout(resolve2, interval);
|
|
32331
32441
|
signal.addEventListener("abort", () => {
|
|
32332
32442
|
clearTimeout(timeoutId);
|
|
32333
32443
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -33174,7 +33284,7 @@ class McpServer {
|
|
|
33174
33284
|
let task = createTaskResult.task;
|
|
33175
33285
|
const pollInterval = task.pollInterval ?? 5000;
|
|
33176
33286
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
33177
|
-
await new Promise((
|
|
33287
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
33178
33288
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
33179
33289
|
if (!updatedTask) {
|
|
33180
33290
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -34152,8 +34262,8 @@ init_zod();
|
|
|
34152
34262
|
init_auth();
|
|
34153
34263
|
init_database();
|
|
34154
34264
|
init_connector_resolver();
|
|
34155
|
-
import { existsSync as
|
|
34156
|
-
import { join as
|
|
34265
|
+
import { existsSync as existsSync14, readFileSync as readFileSync8 } from "fs";
|
|
34266
|
+
import { join as join14 } from "path";
|
|
34157
34267
|
import { spawn } from "child_process";
|
|
34158
34268
|
function registerAuthTools(server, stripped) {
|
|
34159
34269
|
server.registerTool("connector_auth_status", {
|
|
@@ -34288,8 +34398,8 @@ function registerAuthTools(server, stripped) {
|
|
|
34288
34398
|
const serverPort = port || 9876;
|
|
34289
34399
|
const oauthUrl = `http://localhost:${serverPort}/oauth/${name}/start`;
|
|
34290
34400
|
if (noBrowser) {
|
|
34291
|
-
const
|
|
34292
|
-
const tokenPaths = getConnectorConfigReadDirs(name,
|
|
34401
|
+
const connectorsHome2 = getConnectorsHome();
|
|
34402
|
+
const tokenPaths = getConnectorConfigReadDirs(name, connectorsHome2).map((dir) => join14(dir, "profiles", "default", "tokens.json"));
|
|
34293
34403
|
let serverRunning = false;
|
|
34294
34404
|
try {
|
|
34295
34405
|
await fetch(`http://localhost:${serverPort}/api/connectors`);
|
|
@@ -34302,13 +34412,13 @@ function registerAuthTools(server, stripped) {
|
|
|
34302
34412
|
stdio: "ignore"
|
|
34303
34413
|
});
|
|
34304
34414
|
serverProc.unref();
|
|
34305
|
-
await new Promise((
|
|
34415
|
+
await new Promise((resolve2) => setTimeout(resolve2, 2000));
|
|
34306
34416
|
}
|
|
34307
34417
|
let attempts = 0;
|
|
34308
34418
|
const maxAttempts = 120;
|
|
34309
34419
|
while (attempts < maxAttempts) {
|
|
34310
|
-
await new Promise((
|
|
34311
|
-
if (tokenPaths.some((tokensPath) =>
|
|
34420
|
+
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
34421
|
+
if (tokenPaths.some((tokensPath) => existsSync14(tokensPath))) {
|
|
34312
34422
|
break;
|
|
34313
34423
|
}
|
|
34314
34424
|
attempts++;
|
|
@@ -34327,7 +34437,7 @@ function registerAuthTools(server, stripped) {
|
|
|
34327
34437
|
};
|
|
34328
34438
|
}
|
|
34329
34439
|
try {
|
|
34330
|
-
const tokensPath = tokenPaths.find((path) =>
|
|
34440
|
+
const tokensPath = tokenPaths.find((path) => existsSync14(path)) ?? tokenPaths[0];
|
|
34331
34441
|
const tokenData = JSON.parse(readFileSync8(tokensPath, "utf-8"));
|
|
34332
34442
|
return {
|
|
34333
34443
|
content: [{
|
|
@@ -34731,7 +34841,7 @@ function listWorkflows(db) {
|
|
|
34731
34841
|
import { spawn as nodeSpawn } from "child_process";
|
|
34732
34842
|
var spawnImpl = nodeSpawn;
|
|
34733
34843
|
async function runStep(step, previousOutput) {
|
|
34734
|
-
return new Promise((
|
|
34844
|
+
return new Promise((resolve2) => {
|
|
34735
34845
|
const args = [...step.args ?? []];
|
|
34736
34846
|
if (previousOutput && previousOutput.trim()) {
|
|
34737
34847
|
args.push("--input", previousOutput.trim().slice(0, 4096));
|
|
@@ -34745,11 +34855,11 @@ async function runStep(step, previousOutput) {
|
|
|
34745
34855
|
proc.stderr.on("data", (d) => {
|
|
34746
34856
|
output += d.toString();
|
|
34747
34857
|
});
|
|
34748
|
-
proc.on("close", (code) =>
|
|
34749
|
-
proc.on("error", () =>
|
|
34858
|
+
proc.on("close", (code) => resolve2({ exitCode: code ?? 1, output }));
|
|
34859
|
+
proc.on("error", () => resolve2({ exitCode: 1, output: "Failed to spawn connectors" }));
|
|
34750
34860
|
setTimeout(() => {
|
|
34751
34861
|
proc.kill();
|
|
34752
|
-
|
|
34862
|
+
resolve2({ exitCode: 124, output: output + `
|
|
34753
34863
|
[timeout]` });
|
|
34754
34864
|
}, 60000);
|
|
34755
34865
|
});
|
|
@@ -34781,7 +34891,7 @@ async function runWorkflow(workflow) {
|
|
|
34781
34891
|
// src/lib/scheduler.ts
|
|
34782
34892
|
import { spawn as spawn3 } from "child_process";
|
|
34783
34893
|
async function runConnectorCommand2(connector, command, args) {
|
|
34784
|
-
return new Promise((
|
|
34894
|
+
return new Promise((resolve2) => {
|
|
34785
34895
|
const cmdArgs = [connector, command, ...args, "--format", "json"];
|
|
34786
34896
|
const proc = spawn3("connectors", ["run", ...cmdArgs], { shell: false });
|
|
34787
34897
|
let output = "";
|
|
@@ -34791,11 +34901,11 @@ async function runConnectorCommand2(connector, command, args) {
|
|
|
34791
34901
|
proc.stderr.on("data", (d) => {
|
|
34792
34902
|
output += d.toString();
|
|
34793
34903
|
});
|
|
34794
|
-
proc.on("close", (code) =>
|
|
34795
|
-
proc.on("error", () =>
|
|
34904
|
+
proc.on("close", (code) => resolve2({ exitCode: code ?? 1, output }));
|
|
34905
|
+
proc.on("error", () => resolve2({ exitCode: 1, output: `Failed to spawn connectors run` }));
|
|
34796
34906
|
setTimeout(() => {
|
|
34797
34907
|
proc.kill();
|
|
34798
|
-
|
|
34908
|
+
resolve2({ exitCode: 124, output: output + `
|
|
34799
34909
|
[timeout]` });
|
|
34800
34910
|
}, 60000);
|
|
34801
34911
|
});
|
|
@@ -35743,9 +35853,9 @@ data:
|
|
|
35743
35853
|
const initRequest = messages.find((m) => isInitializeRequest(m));
|
|
35744
35854
|
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
35745
35855
|
if (this._enableJsonResponse) {
|
|
35746
|
-
return new Promise((
|
|
35856
|
+
return new Promise((resolve2) => {
|
|
35747
35857
|
this._streamMapping.set(streamId, {
|
|
35748
|
-
resolveJson:
|
|
35858
|
+
resolveJson: resolve2,
|
|
35749
35859
|
cleanup: () => {
|
|
35750
35860
|
this._streamMapping.delete(streamId);
|
|
35751
35861
|
}
|