@hasna/connectors 1.4.3 → 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 +558 -397
- package/bin/mcp.js +297 -187
- package/bin/serve.js +491 -330
- 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/index.js
CHANGED
|
@@ -1909,7 +1909,7 @@ var package_default;
|
|
|
1909
1909
|
var init_package = __esm(() => {
|
|
1910
1910
|
package_default = {
|
|
1911
1911
|
name: "@hasna/connectors",
|
|
1912
|
-
version: "1.4.
|
|
1912
|
+
version: "1.4.5",
|
|
1913
1913
|
description: "Open source connector library - Install API connectors with a single command",
|
|
1914
1914
|
type: "module",
|
|
1915
1915
|
bin: {
|
|
@@ -1981,6 +1981,7 @@ var init_package = __esm(() => {
|
|
|
1981
1981
|
},
|
|
1982
1982
|
dependencies: {
|
|
1983
1983
|
"@hasna/events": "0.1.8",
|
|
1984
|
+
"@hasna/paths": "0.1.0",
|
|
1984
1985
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
1985
1986
|
chalk: "^5.3.0",
|
|
1986
1987
|
commander: "^12.1.0",
|
|
@@ -6965,10 +6966,118 @@ Commands:
|
|
|
6965
6966
|
});
|
|
6966
6967
|
});
|
|
6967
6968
|
|
|
6968
|
-
//
|
|
6969
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, writeFileSync } from "fs";
|
|
6969
|
+
// ../../node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
|
|
6970
6970
|
import { homedir } from "os";
|
|
6971
|
-
import {
|
|
6971
|
+
import { join as join2 } from "path";
|
|
6972
|
+
function assertApp(app) {
|
|
6973
|
+
if (typeof app !== "string" || app.length === 0) {
|
|
6974
|
+
throw new TypeError("paths: app must be a non-empty string");
|
|
6975
|
+
}
|
|
6976
|
+
if (!APP_SLUG_RE.test(app)) {
|
|
6977
|
+
throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
|
|
6978
|
+
}
|
|
6979
|
+
}
|
|
6980
|
+
function envOf(options) {
|
|
6981
|
+
return options.env ?? process.env;
|
|
6982
|
+
}
|
|
6983
|
+
function envValue(options, kind) {
|
|
6984
|
+
const value = envOf(options)[KIND_ENV[kind]];
|
|
6985
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
6986
|
+
}
|
|
6987
|
+
function isMacOS(platform) {
|
|
6988
|
+
return platform === "darwin";
|
|
6989
|
+
}
|
|
6990
|
+
function baseDir(kind, options) {
|
|
6991
|
+
const override = envValue(options, kind);
|
|
6992
|
+
if (override)
|
|
6993
|
+
return override;
|
|
6994
|
+
const home = options.home ?? homedir();
|
|
6995
|
+
const platform = options.platform ?? process.platform;
|
|
6996
|
+
if (isMacOS(platform)) {
|
|
6997
|
+
switch (kind) {
|
|
6998
|
+
case "config":
|
|
6999
|
+
case "data":
|
|
7000
|
+
return join2(home, "Library", "Application Support", "Hasna");
|
|
7001
|
+
case "cache":
|
|
7002
|
+
return join2(home, "Library", "Caches", "Hasna");
|
|
7003
|
+
case "state":
|
|
7004
|
+
return join2(home, "Library", "Logs", "Hasna");
|
|
7005
|
+
}
|
|
7006
|
+
}
|
|
7007
|
+
switch (kind) {
|
|
7008
|
+
case "config":
|
|
7009
|
+
return join2(home, ".config", "hasna");
|
|
7010
|
+
case "data":
|
|
7011
|
+
return join2(home, ".local", "share", "hasna");
|
|
7012
|
+
case "state":
|
|
7013
|
+
return join2(home, ".local", "state", "hasna");
|
|
7014
|
+
case "cache":
|
|
7015
|
+
return join2(home, ".cache", "hasna");
|
|
7016
|
+
}
|
|
7017
|
+
}
|
|
7018
|
+
function resolvePath(kind, options) {
|
|
7019
|
+
assertApp(options.app);
|
|
7020
|
+
const appSegment = options.internal === true ? join2("internal", options.app) : options.app;
|
|
7021
|
+
return join2(baseDir(kind, options), appSegment);
|
|
7022
|
+
}
|
|
7023
|
+
function dataDir(options) {
|
|
7024
|
+
return resolvePath("data", options);
|
|
7025
|
+
}
|
|
7026
|
+
var KIND_ENV, APP_SLUG_RE;
|
|
7027
|
+
var init_dist = __esm(() => {
|
|
7028
|
+
KIND_ENV = {
|
|
7029
|
+
config: "HASNA_CONFIG_HOME",
|
|
7030
|
+
data: "HASNA_DATA_HOME",
|
|
7031
|
+
state: "HASNA_STATE_HOME",
|
|
7032
|
+
cache: "HASNA_CACHE_HOME"
|
|
7033
|
+
};
|
|
7034
|
+
APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
7035
|
+
});
|
|
7036
|
+
|
|
7037
|
+
// src/lib/paths.ts
|
|
7038
|
+
import { existsSync as existsSync2 } from "fs";
|
|
7039
|
+
import { homedir as homedir2 } from "os";
|
|
7040
|
+
import { join as join3, resolve } from "path";
|
|
7041
|
+
function envOr(name, fallback) {
|
|
7042
|
+
const value = process.env[name]?.trim();
|
|
7043
|
+
return value ? value : fallback;
|
|
7044
|
+
}
|
|
7045
|
+
function effectiveHome() {
|
|
7046
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir2();
|
|
7047
|
+
}
|
|
7048
|
+
function legacyHomeDir() {
|
|
7049
|
+
return join3(effectiveHome(), ".hasna", "connectors");
|
|
7050
|
+
}
|
|
7051
|
+
function resolverHome() {
|
|
7052
|
+
return dataDir({
|
|
7053
|
+
app: "connectors",
|
|
7054
|
+
home: process.env["HOME"] || process.env["USERPROFILE"] || undefined
|
|
7055
|
+
});
|
|
7056
|
+
}
|
|
7057
|
+
function adoptResolverHome(resolved, env = process.env) {
|
|
7058
|
+
const dataOverride = env.HASNA_DATA_HOME;
|
|
7059
|
+
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
7060
|
+
return true;
|
|
7061
|
+
return existsSync2(join3(resolved, "connectors.db"));
|
|
7062
|
+
}
|
|
7063
|
+
function exactConnectorsHome() {
|
|
7064
|
+
const home = envOr("HASNA_CONNECTORS_DIR", "");
|
|
7065
|
+
return home ? home : undefined;
|
|
7066
|
+
}
|
|
7067
|
+
function connectorsHome() {
|
|
7068
|
+
const exact = exactConnectorsHome();
|
|
7069
|
+
if (exact)
|
|
7070
|
+
return resolve(exact);
|
|
7071
|
+
const resolved = resolverHome();
|
|
7072
|
+
return adoptResolverHome(resolved) ? resolve(resolved) : resolve(legacyHomeDir());
|
|
7073
|
+
}
|
|
7074
|
+
var init_paths = __esm(() => {
|
|
7075
|
+
init_dist();
|
|
7076
|
+
});
|
|
7077
|
+
|
|
7078
|
+
// src/core/connectors/gmail.ts
|
|
7079
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync, readdirSync, writeFileSync } from "fs";
|
|
7080
|
+
import { basename, join as join4 } from "path";
|
|
6972
7081
|
async function modifyMessage(profile, messageId, addLabelIds, removeLabelIds) {
|
|
6973
7082
|
return requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}/modify`, {}, {
|
|
6974
7083
|
method: "POST",
|
|
@@ -7005,7 +7114,7 @@ async function replyToMessage(profile, messageId, input) {
|
|
|
7005
7114
|
}
|
|
7006
7115
|
async function downloadAttachments(profile, input) {
|
|
7007
7116
|
const messageId = getMessageId(input);
|
|
7008
|
-
const outputDir = input.dir ?? input.outputDir ??
|
|
7117
|
+
const outputDir = input.dir ?? input.outputDir ?? join4(configDirs()[0], "attachments", messageId);
|
|
7009
7118
|
mkdirSync(outputDir, { recursive: true });
|
|
7010
7119
|
const attachments = input.attachmentId && input.filename ? [{
|
|
7011
7120
|
attachmentId: input.attachmentId,
|
|
@@ -7017,7 +7126,7 @@ async function downloadAttachments(profile, input) {
|
|
|
7017
7126
|
for (const attachment of attachments) {
|
|
7018
7127
|
const data = await requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachment.attachmentId)}`, {});
|
|
7019
7128
|
const filename = safeFilename(attachment.filename);
|
|
7020
|
-
const path =
|
|
7129
|
+
const path = join4(outputDir, filename);
|
|
7021
7130
|
const buffer = Buffer.from(data.data, "base64url");
|
|
7022
7131
|
writeFileSync(path, buffer);
|
|
7023
7132
|
downloaded.push({
|
|
@@ -7087,7 +7196,7 @@ function gmailBackoffDelayMs(attempt, retryAfter = null) {
|
|
|
7087
7196
|
return Math.min(2 ** attempt * baseMs + jitterMs, 64000);
|
|
7088
7197
|
}
|
|
7089
7198
|
function sleep(ms) {
|
|
7090
|
-
return new Promise((
|
|
7199
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
7091
7200
|
}
|
|
7092
7201
|
async function getValidAccessToken(profile) {
|
|
7093
7202
|
if (process.env.GMAIL_ACCESS_TOKEN)
|
|
@@ -7133,9 +7242,9 @@ async function refreshAccessToken(profile, currentTokens) {
|
|
|
7133
7242
|
}
|
|
7134
7243
|
function listProfiles() {
|
|
7135
7244
|
const profiles = new Set;
|
|
7136
|
-
for (const
|
|
7137
|
-
const profilesDir =
|
|
7138
|
-
if (!
|
|
7245
|
+
for (const baseDir2 of configDirs()) {
|
|
7246
|
+
const profilesDir = join4(baseDir2, "profiles");
|
|
7247
|
+
if (!existsSync3(profilesDir))
|
|
7139
7248
|
continue;
|
|
7140
7249
|
for (const entry of readdirSync(profilesDir, { withFileTypes: true })) {
|
|
7141
7250
|
if (entry.isDirectory())
|
|
@@ -7151,10 +7260,10 @@ function loadCredentials(profile) {
|
|
|
7151
7260
|
const envClientSecret = process.env.GMAIL_CLIENT_SECRET ?? process.env.GOOGLE_CLIENT_SECRET;
|
|
7152
7261
|
if (envClientId && envClientSecret)
|
|
7153
7262
|
return { clientId: envClientId, clientSecret: envClientSecret };
|
|
7154
|
-
for (const
|
|
7263
|
+
for (const baseDir2 of configDirs()) {
|
|
7155
7264
|
const credentials = {
|
|
7156
|
-
...readJson(
|
|
7157
|
-
...readJson(
|
|
7265
|
+
...readJson(join4(baseDir2, "credentials.json")),
|
|
7266
|
+
...readJson(join4(baseDir2, "profiles", profile, "config.json"))
|
|
7158
7267
|
};
|
|
7159
7268
|
if (credentials.clientId || credentials.clientSecret)
|
|
7160
7269
|
return credentials;
|
|
@@ -7162,31 +7271,31 @@ function loadCredentials(profile) {
|
|
|
7162
7271
|
return {};
|
|
7163
7272
|
}
|
|
7164
7273
|
function loadTokens(profile) {
|
|
7165
|
-
for (const
|
|
7166
|
-
const fromProfile = readJson(
|
|
7274
|
+
for (const baseDir2 of configDirs()) {
|
|
7275
|
+
const fromProfile = readJson(join4(baseDir2, "profiles", profile, "tokens.json"));
|
|
7167
7276
|
if (fromProfile)
|
|
7168
7277
|
return fromProfile;
|
|
7169
|
-
const flat = readJson(
|
|
7278
|
+
const flat = readJson(join4(baseDir2, "profiles", `${profile}.json`));
|
|
7170
7279
|
if (flat)
|
|
7171
7280
|
return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
|
|
7172
7281
|
}
|
|
7173
7282
|
return null;
|
|
7174
7283
|
}
|
|
7175
7284
|
function saveTokens(profile, tokens) {
|
|
7176
|
-
const
|
|
7177
|
-
const profileDir =
|
|
7285
|
+
const baseDir2 = configDirs().find((dir) => existsSync3(dir)) ?? configDirs()[0];
|
|
7286
|
+
const profileDir = join4(baseDir2, "profiles", profile);
|
|
7178
7287
|
mkdirSync(profileDir, { recursive: true });
|
|
7179
|
-
writeFileSync(
|
|
7288
|
+
writeFileSync(join4(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
7180
7289
|
}
|
|
7181
7290
|
function configDirs() {
|
|
7182
7291
|
const explicit = process.env.HASNA_GMAIL_CONNECTOR_DIR ?? process.env.GMAIL_CONNECTOR_DIR;
|
|
7183
7292
|
if (explicit)
|
|
7184
7293
|
return [explicit];
|
|
7185
|
-
const
|
|
7186
|
-
return [
|
|
7294
|
+
const baseDir2 = connectorsHome();
|
|
7295
|
+
return [join4(baseDir2, "gmail"), join4(baseDir2, "connect-gmail")];
|
|
7187
7296
|
}
|
|
7188
7297
|
function readJson(path) {
|
|
7189
|
-
if (!
|
|
7298
|
+
if (!existsSync3(path))
|
|
7190
7299
|
return null;
|
|
7191
7300
|
try {
|
|
7192
7301
|
return JSON.parse(readFileSync(path, "utf8"));
|
|
@@ -7267,6 +7376,7 @@ function safeFilename(filename) {
|
|
|
7267
7376
|
}
|
|
7268
7377
|
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;
|
|
7269
7378
|
var init_gmail = __esm(() => {
|
|
7379
|
+
init_paths();
|
|
7270
7380
|
init_zod();
|
|
7271
7381
|
init_connector();
|
|
7272
7382
|
REFRESH_BUFFER_MS = 5 * 60 * 1000;
|
|
@@ -7436,9 +7546,8 @@ var init_gmail = __esm(() => {
|
|
|
7436
7546
|
});
|
|
7437
7547
|
|
|
7438
7548
|
// src/core/connectors/googledrive.ts
|
|
7439
|
-
import { existsSync as
|
|
7440
|
-
import {
|
|
7441
|
-
import { basename as basename2, join as join3 } from "path";
|
|
7549
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
7550
|
+
import { basename as basename2, join as join5 } from "path";
|
|
7442
7551
|
async function requestJson2(profile, path, params) {
|
|
7443
7552
|
const response = await request(profile, path, params);
|
|
7444
7553
|
const text = await response.text();
|
|
@@ -7505,9 +7614,9 @@ async function refreshAccessToken2(profile, currentTokens) {
|
|
|
7505
7614
|
}
|
|
7506
7615
|
function listProfiles2() {
|
|
7507
7616
|
const profiles = new Set;
|
|
7508
|
-
for (const
|
|
7509
|
-
const profilesDir =
|
|
7510
|
-
if (!
|
|
7617
|
+
for (const baseDir2 of configDirs2()) {
|
|
7618
|
+
const profilesDir = join5(baseDir2, "profiles");
|
|
7619
|
+
if (!existsSync4(profilesDir))
|
|
7511
7620
|
continue;
|
|
7512
7621
|
for (const entry of readdirSync2(profilesDir, { withFileTypes: true })) {
|
|
7513
7622
|
if (entry.isDirectory())
|
|
@@ -7552,10 +7661,10 @@ function loadCredentials2(profile) {
|
|
|
7552
7661
|
const envClientSecret = process.env.GOOGLE_CLIENT_SECRET;
|
|
7553
7662
|
if (envClientId && envClientSecret)
|
|
7554
7663
|
return { clientId: envClientId, clientSecret: envClientSecret };
|
|
7555
|
-
for (const
|
|
7664
|
+
for (const baseDir2 of configDirs2()) {
|
|
7556
7665
|
const credentials = {
|
|
7557
|
-
...readJson2(
|
|
7558
|
-
...readJson2(
|
|
7666
|
+
...readJson2(join5(baseDir2, "credentials.json")),
|
|
7667
|
+
...readJson2(join5(baseDir2, "profiles", profile, "config.json"))
|
|
7559
7668
|
};
|
|
7560
7669
|
if (credentials.clientId || credentials.clientSecret)
|
|
7561
7670
|
return credentials;
|
|
@@ -7563,31 +7672,31 @@ function loadCredentials2(profile) {
|
|
|
7563
7672
|
return {};
|
|
7564
7673
|
}
|
|
7565
7674
|
function loadTokens2(profile) {
|
|
7566
|
-
for (const
|
|
7567
|
-
const fromProfile = readJson2(
|
|
7675
|
+
for (const baseDir2 of configDirs2()) {
|
|
7676
|
+
const fromProfile = readJson2(join5(baseDir2, "profiles", profile, "tokens.json"));
|
|
7568
7677
|
if (fromProfile)
|
|
7569
7678
|
return fromProfile;
|
|
7570
|
-
const flat = readJson2(
|
|
7679
|
+
const flat = readJson2(join5(baseDir2, "profiles", `${profile}.json`));
|
|
7571
7680
|
if (flat)
|
|
7572
7681
|
return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
|
|
7573
7682
|
}
|
|
7574
7683
|
return null;
|
|
7575
7684
|
}
|
|
7576
7685
|
function saveTokens2(profile, tokens) {
|
|
7577
|
-
const
|
|
7578
|
-
const profileDir =
|
|
7686
|
+
const baseDir2 = configDirs2().find((dir) => existsSync4(dir)) ?? configDirs2()[0];
|
|
7687
|
+
const profileDir = join5(baseDir2, "profiles", profile);
|
|
7579
7688
|
mkdirSync2(profileDir, { recursive: true });
|
|
7580
|
-
writeFileSync2(
|
|
7689
|
+
writeFileSync2(join5(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
7581
7690
|
}
|
|
7582
7691
|
function configDirs2() {
|
|
7583
7692
|
const explicit = process.env.HASNA_GOOGLE_DRIVE_CONNECTOR_DIR ?? process.env.GOOGLE_DRIVE_CONNECTOR_DIR;
|
|
7584
7693
|
if (explicit)
|
|
7585
7694
|
return [explicit];
|
|
7586
|
-
const
|
|
7587
|
-
return [
|
|
7695
|
+
const baseDir2 = connectorsHome();
|
|
7696
|
+
return [join5(baseDir2, "googledrive"), join5(baseDir2, "connect-googledrive")];
|
|
7588
7697
|
}
|
|
7589
7698
|
function readJson2(path) {
|
|
7590
|
-
if (!
|
|
7699
|
+
if (!existsSync4(path))
|
|
7591
7700
|
return null;
|
|
7592
7701
|
try {
|
|
7593
7702
|
return JSON.parse(readFileSync2(path, "utf8"));
|
|
@@ -7621,6 +7730,7 @@ function extractGoogleError(body) {
|
|
|
7621
7730
|
}
|
|
7622
7731
|
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;
|
|
7623
7732
|
var init_googledrive = __esm(() => {
|
|
7733
|
+
init_paths();
|
|
7624
7734
|
init_zod();
|
|
7625
7735
|
init_connector();
|
|
7626
7736
|
REFRESH_BUFFER_MS2 = 5 * 60 * 1000;
|
|
@@ -7834,33 +7944,32 @@ __export(exports_database, {
|
|
|
7834
7944
|
closeDatabase: () => closeDatabase,
|
|
7835
7945
|
SqliteAdapter: () => SqliteAdapter
|
|
7836
7946
|
});
|
|
7837
|
-
import { dirname as dirname2, join as
|
|
7838
|
-
import {
|
|
7839
|
-
import { mkdirSync as mkdirSync3, existsSync as existsSync4, readdirSync as readdirSync3, copyFileSync, statSync } from "fs";
|
|
7947
|
+
import { dirname as dirname2, join as join6 } from "path";
|
|
7948
|
+
import { mkdirSync as mkdirSync3, existsSync as existsSync5, readdirSync as readdirSync3, copyFileSync, statSync } from "fs";
|
|
7840
7949
|
function mergeDirectoryContents(sourceDir, targetDir) {
|
|
7841
|
-
if (!
|
|
7950
|
+
if (!existsSync5(sourceDir)) {
|
|
7842
7951
|
return;
|
|
7843
7952
|
}
|
|
7844
7953
|
mkdirSync3(targetDir, { recursive: true });
|
|
7845
7954
|
for (const entry of readdirSync3(sourceDir)) {
|
|
7846
|
-
const sourcePath =
|
|
7847
|
-
const targetPath =
|
|
7955
|
+
const sourcePath = join6(sourceDir, entry);
|
|
7956
|
+
const targetPath = join6(targetDir, entry);
|
|
7848
7957
|
try {
|
|
7849
7958
|
const sourceStat = statSync(sourcePath);
|
|
7850
7959
|
if (sourceStat.isDirectory()) {
|
|
7851
7960
|
mergeDirectoryContents(sourcePath, targetPath);
|
|
7852
7961
|
continue;
|
|
7853
7962
|
}
|
|
7854
|
-
if (!
|
|
7963
|
+
if (!existsSync5(targetPath)) {
|
|
7855
7964
|
copyFileSync(sourcePath, targetPath);
|
|
7856
7965
|
}
|
|
7857
7966
|
} catch {}
|
|
7858
7967
|
}
|
|
7859
7968
|
}
|
|
7860
7969
|
function getConnectorsHome() {
|
|
7861
|
-
const
|
|
7862
|
-
const
|
|
7863
|
-
const legacyDirs = [
|
|
7970
|
+
const newDir = connectorsHome();
|
|
7971
|
+
const home = effectiveHome();
|
|
7972
|
+
const legacyDirs = [join6(home, ".connectors"), join6(home, ".connect")];
|
|
7864
7973
|
mkdirSync3(newDir, { recursive: true });
|
|
7865
7974
|
for (const legacyDir of legacyDirs) {
|
|
7866
7975
|
try {
|
|
@@ -8008,13 +8117,14 @@ var DB_DIR, DB_PATH, _db = null, _dbPath = null;
|
|
|
8008
8117
|
var init_database = __esm(() => {
|
|
8009
8118
|
init_sqlite_adapter();
|
|
8010
8119
|
init_sqlite_adapter();
|
|
8120
|
+
init_paths();
|
|
8011
8121
|
DB_DIR = getConnectorsHome();
|
|
8012
|
-
DB_PATH =
|
|
8122
|
+
DB_PATH = join6(DB_DIR, "connectors.db");
|
|
8013
8123
|
});
|
|
8014
8124
|
|
|
8015
8125
|
// src/lib/connector-resolver.ts
|
|
8016
|
-
import { existsSync as
|
|
8017
|
-
import { join as
|
|
8126
|
+
import { existsSync as existsSync6, readdirSync as readdirSync4, statSync as statSync2 } from "fs";
|
|
8127
|
+
import { join as join7 } from "path";
|
|
8018
8128
|
function stripLegacyPrefix(name) {
|
|
8019
8129
|
return name.startsWith(LEGACY_CONNECTOR_PREFIX) ? name.slice(LEGACY_CONNECTOR_PREFIX.length) : name;
|
|
8020
8130
|
}
|
|
@@ -8057,8 +8167,8 @@ function connectorPackageDirNames(name) {
|
|
|
8057
8167
|
function resolveConnectorPackagePath(connectorsDir, name) {
|
|
8058
8168
|
const resolution = resolveConnectorName(name);
|
|
8059
8169
|
const dirNames = connectorPackageDirNames(name);
|
|
8060
|
-
const checkedPaths = dirNames.map((dirName) =>
|
|
8061
|
-
const existingPath = checkedPaths.find((path) =>
|
|
8170
|
+
const checkedPaths = dirNames.map((dirName) => join7(connectorsDir, dirName));
|
|
8171
|
+
const existingPath = checkedPaths.find((path) => existsSync6(path)) ?? null;
|
|
8062
8172
|
const existingDirName = existingPath ? dirNames[checkedPaths.indexOf(existingPath)] : null;
|
|
8063
8173
|
return {
|
|
8064
8174
|
...resolution,
|
|
@@ -8074,16 +8184,16 @@ function getConnectorPackagePath(connectorsDir, name) {
|
|
|
8074
8184
|
const resolved = resolveConnectorPackagePath(connectorsDir, name);
|
|
8075
8185
|
return resolved.existingPath ?? resolved.preferredPath;
|
|
8076
8186
|
}
|
|
8077
|
-
function resolveConnectorConfigPaths(name,
|
|
8187
|
+
function resolveConnectorConfigPaths(name, connectorsHome2 = getConnectorsHome()) {
|
|
8078
8188
|
const resolution = resolveConnectorName(name);
|
|
8079
8189
|
const preferredDirName = resolution.canonicalName || resolution.legacyName;
|
|
8080
|
-
const preferredPath =
|
|
8081
|
-
const legacyPath =
|
|
8190
|
+
const preferredPath = join7(connectorsHome2, preferredDirName);
|
|
8191
|
+
const legacyPath = join7(connectorsHome2, resolution.legacyName);
|
|
8082
8192
|
const paths = preferredPath === legacyPath ? [preferredPath] : [preferredPath, legacyPath];
|
|
8083
|
-
const existingPaths = paths.filter((path) =>
|
|
8193
|
+
const existingPaths = paths.filter((path) => existsSync6(path));
|
|
8084
8194
|
return {
|
|
8085
8195
|
...resolution,
|
|
8086
|
-
connectorsHome,
|
|
8196
|
+
connectorsHome: connectorsHome2,
|
|
8087
8197
|
preferredDirName,
|
|
8088
8198
|
preferredPath,
|
|
8089
8199
|
legacyPath,
|
|
@@ -8091,18 +8201,18 @@ function resolveConnectorConfigPaths(name, connectorsHome = getConnectorsHome())
|
|
|
8091
8201
|
readPaths: paths
|
|
8092
8202
|
};
|
|
8093
8203
|
}
|
|
8094
|
-
function getConnectorConfigDir(name,
|
|
8095
|
-
return resolveConnectorConfigPaths(name,
|
|
8204
|
+
function getConnectorConfigDir(name, connectorsHome2 = getConnectorsHome()) {
|
|
8205
|
+
return resolveConnectorConfigPaths(name, connectorsHome2).preferredPath;
|
|
8096
8206
|
}
|
|
8097
|
-
function getConnectorConfigReadDirs(name,
|
|
8098
|
-
return resolveConnectorConfigPaths(name,
|
|
8207
|
+
function getConnectorConfigReadDirs(name, connectorsHome2 = getConnectorsHome()) {
|
|
8208
|
+
return resolveConnectorConfigPaths(name, connectorsHome2).readPaths;
|
|
8099
8209
|
}
|
|
8100
|
-
function listConfiguredConnectorNames(
|
|
8101
|
-
if (!
|
|
8210
|
+
function listConfiguredConnectorNames(connectorsHome2 = getConnectorsHome()) {
|
|
8211
|
+
if (!existsSync6(connectorsHome2))
|
|
8102
8212
|
return [];
|
|
8103
8213
|
const names = new Set;
|
|
8104
|
-
for (const entry of readdirSync4(
|
|
8105
|
-
const fullPath =
|
|
8214
|
+
for (const entry of readdirSync4(connectorsHome2)) {
|
|
8215
|
+
const fullPath = join7(connectorsHome2, entry);
|
|
8106
8216
|
try {
|
|
8107
8217
|
if (!statSync2(fullPath).isDirectory())
|
|
8108
8218
|
continue;
|
|
@@ -8125,7 +8235,7 @@ var init_connector_resolver = __esm(() => {
|
|
|
8125
8235
|
|
|
8126
8236
|
// src/core/connectors/imessage.ts
|
|
8127
8237
|
import {
|
|
8128
|
-
existsSync as
|
|
8238
|
+
existsSync as existsSync7,
|
|
8129
8239
|
mkdirSync as mkdirSync4,
|
|
8130
8240
|
readFileSync as readFileSync3,
|
|
8131
8241
|
readdirSync as readdirSync5,
|
|
@@ -8133,7 +8243,7 @@ import {
|
|
|
8133
8243
|
statSync as statSync3,
|
|
8134
8244
|
writeFileSync as writeFileSync3
|
|
8135
8245
|
} from "fs";
|
|
8136
|
-
import { join as
|
|
8246
|
+
import { join as join8 } from "path";
|
|
8137
8247
|
function buildRootHelp(specs) {
|
|
8138
8248
|
const lines = [
|
|
8139
8249
|
"Usage: connect-imessage [options] [command]",
|
|
@@ -8184,12 +8294,12 @@ function getConfigReadDirs() {
|
|
|
8184
8294
|
return getConnectorConfigReadDirs(CONNECTOR_NAME);
|
|
8185
8295
|
}
|
|
8186
8296
|
function getProfilesDir() {
|
|
8187
|
-
return
|
|
8297
|
+
return join8(getConfigDir(), "profiles");
|
|
8188
8298
|
}
|
|
8189
8299
|
function getCurrentProfile() {
|
|
8190
8300
|
for (const configDir of getConfigReadDirs()) {
|
|
8191
|
-
const currentProfileFile =
|
|
8192
|
-
if (!
|
|
8301
|
+
const currentProfileFile = join8(configDir, "current_profile");
|
|
8302
|
+
if (!existsSync7(currentProfileFile))
|
|
8193
8303
|
continue;
|
|
8194
8304
|
try {
|
|
8195
8305
|
return readFileSync3(currentProfileFile, "utf-8").trim() || "default";
|
|
@@ -8202,16 +8312,16 @@ function getCurrentProfile() {
|
|
|
8202
8312
|
function setCurrentProfile(profile) {
|
|
8203
8313
|
const configDir = getConfigDir();
|
|
8204
8314
|
mkdirSync4(configDir, { recursive: true });
|
|
8205
|
-
writeFileSync3(
|
|
8315
|
+
writeFileSync3(join8(configDir, "current_profile"), profile);
|
|
8206
8316
|
}
|
|
8207
8317
|
function getFlatProfilePath(profile) {
|
|
8208
|
-
return
|
|
8318
|
+
return join8(getProfilesDir(), `${profile}.json`);
|
|
8209
8319
|
}
|
|
8210
8320
|
function getFlatProfileReadPaths(profile) {
|
|
8211
|
-
return getConfigReadDirs().map((dir) =>
|
|
8321
|
+
return getConfigReadDirs().map((dir) => join8(dir, "profiles", `${profile}.json`));
|
|
8212
8322
|
}
|
|
8213
8323
|
function getDirectoryProfileReadPaths(profile) {
|
|
8214
|
-
return getConfigReadDirs().map((dir) =>
|
|
8324
|
+
return getConfigReadDirs().map((dir) => join8(dir, "profiles", profile, "config.json"));
|
|
8215
8325
|
}
|
|
8216
8326
|
function loadJsonFile(path) {
|
|
8217
8327
|
try {
|
|
@@ -8231,8 +8341,8 @@ function sanitizeProfileConfig(config) {
|
|
|
8231
8341
|
};
|
|
8232
8342
|
}
|
|
8233
8343
|
function loadProfile(profile = getCurrentProfile()) {
|
|
8234
|
-
const flatConfig = getFlatProfileReadPaths(profile).reverse().reduce((config, path) => ({ ...config, ...
|
|
8235
|
-
const directoryConfig = getDirectoryProfileReadPaths(profile).reverse().reduce((config, path) => ({ ...config, ...
|
|
8344
|
+
const flatConfig = getFlatProfileReadPaths(profile).reverse().reduce((config, path) => ({ ...config, ...existsSync7(path) ? loadJsonFile(path) : {} }), {});
|
|
8345
|
+
const directoryConfig = getDirectoryProfileReadPaths(profile).reverse().reduce((config, path) => ({ ...config, ...existsSync7(path) ? loadJsonFile(path) : {} }), {});
|
|
8236
8346
|
return sanitizeProfileConfig({
|
|
8237
8347
|
...flatConfig,
|
|
8238
8348
|
...directoryConfig
|
|
@@ -8248,17 +8358,17 @@ function profileExists(profile) {
|
|
|
8248
8358
|
if (profile === "default") {
|
|
8249
8359
|
return true;
|
|
8250
8360
|
}
|
|
8251
|
-
return getFlatProfileReadPaths(profile).some((path) =>
|
|
8361
|
+
return getFlatProfileReadPaths(profile).some((path) => existsSync7(path)) || getConfigReadDirs().some((dir) => existsSync7(join8(dir, "profiles", profile)));
|
|
8252
8362
|
}
|
|
8253
8363
|
function listProfiles3() {
|
|
8254
8364
|
const seen = new Set(["default"]);
|
|
8255
8365
|
for (const configDir of getConfigReadDirs()) {
|
|
8256
|
-
const profilesDir =
|
|
8257
|
-
if (!
|
|
8366
|
+
const profilesDir = join8(configDir, "profiles");
|
|
8367
|
+
if (!existsSync7(profilesDir))
|
|
8258
8368
|
continue;
|
|
8259
8369
|
try {
|
|
8260
8370
|
for (const entry of readdirSync5(profilesDir)) {
|
|
8261
|
-
const fullPath =
|
|
8371
|
+
const fullPath = join8(profilesDir, entry);
|
|
8262
8372
|
const stat = statSync3(fullPath);
|
|
8263
8373
|
if (stat.isDirectory()) {
|
|
8264
8374
|
seen.add(entry);
|
|
@@ -8280,11 +8390,11 @@ function createProfile(profile, config = {}) {
|
|
|
8280
8390
|
}
|
|
8281
8391
|
function clearProfile(profile = getCurrentProfile()) {
|
|
8282
8392
|
const flatPath = getFlatProfilePath(profile);
|
|
8283
|
-
const directoryPath =
|
|
8284
|
-
if (
|
|
8393
|
+
const directoryPath = join8(getProfilesDir(), profile);
|
|
8394
|
+
if (existsSync7(flatPath)) {
|
|
8285
8395
|
rmSync(flatPath);
|
|
8286
8396
|
}
|
|
8287
|
-
if (
|
|
8397
|
+
if (existsSync7(directoryPath)) {
|
|
8288
8398
|
rmSync(directoryPath, { recursive: true, force: true });
|
|
8289
8399
|
}
|
|
8290
8400
|
}
|
|
@@ -9210,18 +9320,18 @@ var init_imessage = __esm(() => {
|
|
|
9210
9320
|
});
|
|
9211
9321
|
|
|
9212
9322
|
// src/core/connectors/stripe.ts
|
|
9213
|
-
import { existsSync as
|
|
9214
|
-
import { dirname as dirname3, join as
|
|
9323
|
+
import { existsSync as existsSync8 } from "fs";
|
|
9324
|
+
import { dirname as dirname3, join as join9 } from "path";
|
|
9215
9325
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
|
|
9216
9326
|
function resolveStripeConnectorDir() {
|
|
9217
9327
|
const candidates = [
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9328
|
+
join9(__dirname3, "..", "..", "..", "connectors", "stripe"),
|
|
9329
|
+
join9(__dirname3, "..", "..", "connectors", "stripe"),
|
|
9330
|
+
join9(__dirname3, "..", "connectors", "stripe"),
|
|
9331
|
+
join9(process.cwd(), "connectors", "stripe")
|
|
9222
9332
|
];
|
|
9223
9333
|
for (const candidate of candidates) {
|
|
9224
|
-
if (
|
|
9334
|
+
if (existsSync8(candidate)) {
|
|
9225
9335
|
return candidate;
|
|
9226
9336
|
}
|
|
9227
9337
|
}
|
|
@@ -9269,10 +9379,10 @@ function buildCommandHelp2(spec) {
|
|
|
9269
9379
|
`);
|
|
9270
9380
|
}
|
|
9271
9381
|
async function loadStripeApiModule() {
|
|
9272
|
-
return await import(pathToFileURL2(
|
|
9382
|
+
return await import(pathToFileURL2(join9(CONNECTOR_DIR2, "src", "api", "index.ts")).href);
|
|
9273
9383
|
}
|
|
9274
9384
|
async function loadStripeConfigModule() {
|
|
9275
|
-
return await import(pathToFileURL2(
|
|
9385
|
+
return await import(pathToFileURL2(join9(CONNECTOR_DIR2, "src", "utils", "config.ts")).href);
|
|
9276
9386
|
}
|
|
9277
9387
|
function extractGlobalArgs3(args) {
|
|
9278
9388
|
const remaining = [];
|
|
@@ -18396,8 +18506,8 @@ __export(exports_registry, {
|
|
|
18396
18506
|
CONNECTORS: () => CONNECTORS,
|
|
18397
18507
|
CATEGORIES: () => CATEGORIES
|
|
18398
18508
|
});
|
|
18399
|
-
import { existsSync as
|
|
18400
|
-
import { join as
|
|
18509
|
+
import { existsSync as existsSync9, readFileSync as readFileSync4 } from "fs";
|
|
18510
|
+
import { join as join10, dirname as dirname4 } from "path";
|
|
18401
18511
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
18402
18512
|
function getConnectorsByCategory(category) {
|
|
18403
18513
|
return CONNECTORS.filter((c) => c.category === category);
|
|
@@ -18561,16 +18671,16 @@ function loadConnectorVersions() {
|
|
|
18561
18671
|
versionsLoaded = true;
|
|
18562
18672
|
const thisDir = dirname4(fileURLToPath3(import.meta.url));
|
|
18563
18673
|
const candidates = [
|
|
18564
|
-
|
|
18565
|
-
|
|
18674
|
+
join10(thisDir, "..", "connectors"),
|
|
18675
|
+
join10(thisDir, "..", "..", "connectors")
|
|
18566
18676
|
];
|
|
18567
|
-
const connectorsDir = candidates.find((d) =>
|
|
18677
|
+
const connectorsDir = candidates.find((d) => existsSync9(d));
|
|
18568
18678
|
if (!connectorsDir)
|
|
18569
18679
|
return;
|
|
18570
18680
|
for (const connector of CONNECTORS) {
|
|
18571
18681
|
try {
|
|
18572
|
-
const pkgPath =
|
|
18573
|
-
if (
|
|
18682
|
+
const pkgPath = join10(getConnectorPackagePath(connectorsDir, connector.name), "package.json");
|
|
18683
|
+
if (existsSync9(pkgPath)) {
|
|
18574
18684
|
const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|
|
18575
18685
|
connector.version = pkg.version || "0.0.0";
|
|
18576
18686
|
continue;
|
|
@@ -20295,30 +20405,30 @@ __export(exports_installer, {
|
|
|
20295
20405
|
getConnectorDocs: () => getConnectorDocs,
|
|
20296
20406
|
connectorExists: () => connectorExists
|
|
20297
20407
|
});
|
|
20298
|
-
import { existsSync as
|
|
20299
|
-
import { join as
|
|
20408
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync4, readdirSync as readdirSync6, statSync as statSync4, rmSync as rmSync2 } from "fs";
|
|
20409
|
+
import { join as join11, dirname as dirname5 } from "path";
|
|
20300
20410
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
20301
20411
|
function resolveConnectorsDir() {
|
|
20302
|
-
const fromBin =
|
|
20303
|
-
if (
|
|
20412
|
+
const fromBin = join11(__dirname4, "..", "connectors");
|
|
20413
|
+
if (existsSync10(fromBin))
|
|
20304
20414
|
return fromBin;
|
|
20305
|
-
const fromSrc =
|
|
20306
|
-
if (
|
|
20415
|
+
const fromSrc = join11(__dirname4, "..", "..", "connectors");
|
|
20416
|
+
if (existsSync10(fromSrc))
|
|
20307
20417
|
return fromSrc;
|
|
20308
20418
|
return fromBin;
|
|
20309
20419
|
}
|
|
20310
20420
|
function getProjectConnectorsDir(targetDir) {
|
|
20311
|
-
return
|
|
20421
|
+
return join11(targetDir, PROJECT_CONNECTORS_DIRNAME);
|
|
20312
20422
|
}
|
|
20313
20423
|
function getEnablementManifestPath(targetDir) {
|
|
20314
|
-
return
|
|
20424
|
+
return join11(getProjectConnectorsDir(targetDir), ENABLEMENT_MANIFEST_FILENAME);
|
|
20315
20425
|
}
|
|
20316
20426
|
function getLegacyInstallPath(targetDir, name) {
|
|
20317
|
-
return
|
|
20427
|
+
return join11(getProjectConnectorsDir(targetDir), legacyConnectorName(name));
|
|
20318
20428
|
}
|
|
20319
20429
|
function loadEnablementManifest(targetDir) {
|
|
20320
20430
|
const manifestPath = getEnablementManifestPath(targetDir);
|
|
20321
|
-
if (!
|
|
20431
|
+
if (!existsSync10(manifestPath)) {
|
|
20322
20432
|
return null;
|
|
20323
20433
|
}
|
|
20324
20434
|
try {
|
|
@@ -20338,11 +20448,11 @@ function loadEnablementManifest(targetDir) {
|
|
|
20338
20448
|
}
|
|
20339
20449
|
function getLegacyInstalledConnectors(targetDir) {
|
|
20340
20450
|
const connectorsDir = getProjectConnectorsDir(targetDir);
|
|
20341
|
-
if (!
|
|
20451
|
+
if (!existsSync10(connectorsDir)) {
|
|
20342
20452
|
return [];
|
|
20343
20453
|
}
|
|
20344
20454
|
return readdirSync6(connectorsDir).filter((entry) => {
|
|
20345
|
-
const fullPath =
|
|
20455
|
+
const fullPath = join11(connectorsDir, entry);
|
|
20346
20456
|
return entry.startsWith("connect-") && statSync4(fullPath).isDirectory();
|
|
20347
20457
|
}).map((entry) => entry.replace("connect-", "")).sort();
|
|
20348
20458
|
}
|
|
@@ -20351,7 +20461,7 @@ function getEnabledConnectors(targetDir) {
|
|
|
20351
20461
|
return [...new Set([...manifestConnectors, ...getLegacyInstalledConnectors(targetDir)])].sort();
|
|
20352
20462
|
}
|
|
20353
20463
|
function updateConnectorsIndex(connectorsDir, connectors18) {
|
|
20354
|
-
const indexPath =
|
|
20464
|
+
const indexPath = join11(connectorsDir, ENABLEMENT_INDEX_FILENAME);
|
|
20355
20465
|
const connectorList = connectors18.map((connector) => ` "${connector}",`).join(`
|
|
20356
20466
|
`);
|
|
20357
20467
|
const content = `/**
|
|
@@ -20387,7 +20497,7 @@ function getConnectorPath(name) {
|
|
|
20387
20497
|
}
|
|
20388
20498
|
function connectorExists(name) {
|
|
20389
20499
|
const normalizedName = normalizeConnectorName(name);
|
|
20390
|
-
return hasInternalConnectorDefinition(normalizedName) ||
|
|
20500
|
+
return hasInternalConnectorDefinition(normalizedName) || existsSync10(getConnectorPath(normalizedName));
|
|
20391
20501
|
}
|
|
20392
20502
|
function installConnector(name, options = {}) {
|
|
20393
20503
|
const { targetDir = process.cwd(), overwrite = false } = options;
|
|
@@ -20420,7 +20530,7 @@ function installConnector(name, options = {}) {
|
|
|
20420
20530
|
try {
|
|
20421
20531
|
const nextEnabled = [...new Set([...installed, normalizedName])].sort();
|
|
20422
20532
|
writeEnablementManifest(targetDir, nextEnabled);
|
|
20423
|
-
if (overwrite &&
|
|
20533
|
+
if (overwrite && existsSync10(legacyInstallPath)) {
|
|
20424
20534
|
rmSync2(legacyInstallPath, { recursive: true });
|
|
20425
20535
|
}
|
|
20426
20536
|
return {
|
|
@@ -20455,8 +20565,8 @@ function parseConnectorDocs(raw) {
|
|
|
20455
20565
|
function getConnectorDocs(name) {
|
|
20456
20566
|
const normalizedName = normalizeConnectorName(name);
|
|
20457
20567
|
const connectorPath = getConnectorPath(normalizedName);
|
|
20458
|
-
const claudeMdPath =
|
|
20459
|
-
if (
|
|
20568
|
+
const claudeMdPath = join11(connectorPath, "CLAUDE.md");
|
|
20569
|
+
if (existsSync10(claudeMdPath)) {
|
|
20460
20570
|
return parseConnectorDocs(readFileSync5(claudeMdPath, "utf-8"));
|
|
20461
20571
|
}
|
|
20462
20572
|
const internalDocs = getInternalConnectorDefinition(normalizedName)?.docsMarkdown;
|
|
@@ -20501,7 +20611,7 @@ function removeConnector(name, targetDir = process.cwd()) {
|
|
|
20501
20611
|
const nextEnabled = installed.filter((connector) => connector !== normalizedName);
|
|
20502
20612
|
writeEnablementManifest(targetDir, nextEnabled);
|
|
20503
20613
|
const legacyInstallPath = getLegacyInstallPath(targetDir, normalizedName);
|
|
20504
|
-
if (
|
|
20614
|
+
if (existsSync10(legacyInstallPath)) {
|
|
20505
20615
|
rmSync2(legacyInstallPath, { recursive: true });
|
|
20506
20616
|
}
|
|
20507
20617
|
return true;
|
|
@@ -20588,7 +20698,7 @@ function maybeTruncateOutput(text, options = {}) {
|
|
|
20588
20698
|
var DEFAULT_COMPACT_LIMIT = 20, DEFAULT_MCP_LIMIT = 20, MAX_COMPACT_LIMIT = 100, DEFAULT_TEXT_WIDTH = 96, DEFAULT_OUTPUT_CHARS = 6000;
|
|
20589
20699
|
|
|
20590
20700
|
// src/lib/lock.ts
|
|
20591
|
-
import { openSync, closeSync, unlinkSync, existsSync as
|
|
20701
|
+
import { openSync, closeSync, unlinkSync, existsSync as existsSync11, statSync as statSync6 } from "fs";
|
|
20592
20702
|
import { mkdirSync as mkdirSync6 } from "fs";
|
|
20593
20703
|
function lockPath(connector) {
|
|
20594
20704
|
const dir = getConnectorConfigDir(connector);
|
|
@@ -20604,7 +20714,7 @@ function isStale(path) {
|
|
|
20604
20714
|
}
|
|
20605
20715
|
}
|
|
20606
20716
|
function tryAcquire(path) {
|
|
20607
|
-
if (
|
|
20717
|
+
if (existsSync11(path) && isStale(path)) {
|
|
20608
20718
|
try {
|
|
20609
20719
|
unlinkSync(path);
|
|
20610
20720
|
} catch {}
|
|
@@ -20636,7 +20746,7 @@ async function withWriteLock(connector, fn) {
|
|
|
20636
20746
|
release(path);
|
|
20637
20747
|
}
|
|
20638
20748
|
}
|
|
20639
|
-
await new Promise((
|
|
20749
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MS));
|
|
20640
20750
|
}
|
|
20641
20751
|
throw new LockTimeoutError(connector);
|
|
20642
20752
|
}
|
|
@@ -20654,9 +20764,9 @@ var init_lock = __esm(() => {
|
|
|
20654
20764
|
});
|
|
20655
20765
|
|
|
20656
20766
|
// src/server/auth.ts
|
|
20657
|
-
import { chmodSync, existsSync as
|
|
20767
|
+
import { chmodSync, existsSync as existsSync12, readFileSync as readFileSync6, writeFileSync as writeFileSync5, mkdirSync as mkdirSync7, readdirSync as readdirSync8, rmSync as rmSync3, statSync as statSync7 } from "fs";
|
|
20658
20768
|
import { randomBytes } from "crypto";
|
|
20659
|
-
import { join as
|
|
20769
|
+
import { join as join13 } from "path";
|
|
20660
20770
|
function getAuthType(name) {
|
|
20661
20771
|
name = normalizeConnectorName(name);
|
|
20662
20772
|
const docs = getConnectorDocs(name);
|
|
@@ -20697,8 +20807,8 @@ function writePrivateText(path, data) {
|
|
|
20697
20807
|
function getCurrentProfile2(name) {
|
|
20698
20808
|
name = normalizeConnectorName(name);
|
|
20699
20809
|
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
20700
|
-
const currentProfileFile =
|
|
20701
|
-
if (
|
|
20810
|
+
const currentProfileFile = join13(configDir, "current_profile");
|
|
20811
|
+
if (existsSync12(currentProfileFile)) {
|
|
20702
20812
|
try {
|
|
20703
20813
|
return readFileSync6(currentProfileFile, "utf-8").trim() || "default";
|
|
20704
20814
|
} catch {
|
|
@@ -20711,14 +20821,14 @@ function getCurrentProfile2(name) {
|
|
|
20711
20821
|
function loadProfileConfigFromDir(configDir, profile) {
|
|
20712
20822
|
let flatConfig = {};
|
|
20713
20823
|
let dirConfig = {};
|
|
20714
|
-
const profileFile =
|
|
20715
|
-
if (
|
|
20824
|
+
const profileFile = join13(configDir, "profiles", `${profile}.json`);
|
|
20825
|
+
if (existsSync12(profileFile)) {
|
|
20716
20826
|
try {
|
|
20717
20827
|
flatConfig = JSON.parse(readFileSync6(profileFile, "utf-8"));
|
|
20718
20828
|
} catch {}
|
|
20719
20829
|
}
|
|
20720
|
-
const profileDirConfig =
|
|
20721
|
-
if (
|
|
20830
|
+
const profileDirConfig = join13(configDir, "profiles", profile, "config.json");
|
|
20831
|
+
if (existsSync12(profileDirConfig)) {
|
|
20722
20832
|
try {
|
|
20723
20833
|
dirConfig = JSON.parse(readFileSync6(profileDirConfig, "utf-8"));
|
|
20724
20834
|
} catch {}
|
|
@@ -20738,8 +20848,8 @@ function loadTokens3(name) {
|
|
|
20738
20848
|
name = normalizeConnectorName(name);
|
|
20739
20849
|
const profile = getCurrentProfile2(name);
|
|
20740
20850
|
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
20741
|
-
const tokensFile =
|
|
20742
|
-
if (
|
|
20851
|
+
const tokensFile = join13(configDir, "profiles", profile, "tokens.json");
|
|
20852
|
+
if (existsSync12(tokensFile)) {
|
|
20743
20853
|
try {
|
|
20744
20854
|
return JSON.parse(readFileSync6(tokensFile, "utf-8"));
|
|
20745
20855
|
} catch {
|
|
@@ -20872,10 +20982,10 @@ function _saveApiKey(name, key, field) {
|
|
|
20872
20982
|
const profile = getCurrentProfile2(name);
|
|
20873
20983
|
const keyField = field || guessKeyField(name);
|
|
20874
20984
|
if (keyField === "clientId" || keyField === "clientSecret") {
|
|
20875
|
-
const credentialsFile =
|
|
20985
|
+
const credentialsFile = join13(configDir, "credentials.json");
|
|
20876
20986
|
ensurePrivateDir(configDir);
|
|
20877
20987
|
let creds = {};
|
|
20878
|
-
if (
|
|
20988
|
+
if (existsSync12(credentialsFile)) {
|
|
20879
20989
|
try {
|
|
20880
20990
|
creds = JSON.parse(readFileSync6(credentialsFile, "utf-8"));
|
|
20881
20991
|
} catch {}
|
|
@@ -20884,10 +20994,10 @@ function _saveApiKey(name, key, field) {
|
|
|
20884
20994
|
writePrivateJson(credentialsFile, creds);
|
|
20885
20995
|
return;
|
|
20886
20996
|
}
|
|
20887
|
-
const profilesDir =
|
|
20888
|
-
const profileFile =
|
|
20889
|
-
const profileDir =
|
|
20890
|
-
if (
|
|
20997
|
+
const profilesDir = join13(configDir, "profiles");
|
|
20998
|
+
const profileFile = join13(profilesDir, `${profile}.json`);
|
|
20999
|
+
const profileDir = join13(profilesDir, profile);
|
|
21000
|
+
if (existsSync12(profileFile)) {
|
|
20891
21001
|
let config = {};
|
|
20892
21002
|
try {
|
|
20893
21003
|
config = JSON.parse(readFileSync6(profileFile, "utf-8"));
|
|
@@ -20898,10 +21008,10 @@ function _saveApiKey(name, key, field) {
|
|
|
20898
21008
|
writePrivateJson(profileFile, config);
|
|
20899
21009
|
return;
|
|
20900
21010
|
}
|
|
20901
|
-
if (
|
|
20902
|
-
const configFile =
|
|
21011
|
+
if (existsSync12(profileDir)) {
|
|
21012
|
+
const configFile = join13(profileDir, "config.json");
|
|
20903
21013
|
let config = {};
|
|
20904
|
-
if (
|
|
21014
|
+
if (existsSync12(configFile)) {
|
|
20905
21015
|
try {
|
|
20906
21016
|
config = JSON.parse(readFileSync6(configFile, "utf-8"));
|
|
20907
21017
|
} catch {}
|
|
@@ -20916,7 +21026,7 @@ function _saveApiKey(name, key, field) {
|
|
|
20916
21026
|
ensurePrivateDir(configDir);
|
|
20917
21027
|
ensurePrivateDir(profilesDir);
|
|
20918
21028
|
ensurePrivateDir(profileDir);
|
|
20919
|
-
writePrivateJson(
|
|
21029
|
+
writePrivateJson(join13(profileDir, "config.json"), { [keyField]: key });
|
|
20920
21030
|
}
|
|
20921
21031
|
function guessKeyField(name) {
|
|
20922
21032
|
name = normalizeConnectorName(name);
|
|
@@ -20938,8 +21048,8 @@ function guessKeyField(name) {
|
|
|
20938
21048
|
function getOAuthConfig(name) {
|
|
20939
21049
|
name = normalizeConnectorName(name);
|
|
20940
21050
|
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
20941
|
-
const credentialsFile =
|
|
20942
|
-
if (
|
|
21051
|
+
const credentialsFile = join13(configDir, "credentials.json");
|
|
21052
|
+
if (existsSync12(credentialsFile)) {
|
|
20943
21053
|
try {
|
|
20944
21054
|
const creds = JSON.parse(readFileSync6(credentialsFile, "utf-8"));
|
|
20945
21055
|
return { clientId: creds.clientId, clientSecret: creds.clientSecret };
|
|
@@ -21025,12 +21135,12 @@ function saveOAuthTokens(name, tokens) {
|
|
|
21025
21135
|
name = normalizeConnectorName(name);
|
|
21026
21136
|
const configDir = getConnectorConfigDir2(name);
|
|
21027
21137
|
const profile = getCurrentProfile2(name);
|
|
21028
|
-
const profilesDir =
|
|
21029
|
-
const profileDir =
|
|
21138
|
+
const profilesDir = join13(configDir, "profiles");
|
|
21139
|
+
const profileDir = join13(profilesDir, profile);
|
|
21030
21140
|
ensurePrivateDir(configDir);
|
|
21031
21141
|
ensurePrivateDir(profilesDir);
|
|
21032
21142
|
ensurePrivateDir(profileDir);
|
|
21033
|
-
const tokensFile =
|
|
21143
|
+
const tokensFile = join13(profileDir, "tokens.json");
|
|
21034
21144
|
writePrivateJson(tokensFile, tokens);
|
|
21035
21145
|
}
|
|
21036
21146
|
async function refreshOAuthToken(name) {
|
|
@@ -21077,13 +21187,13 @@ function listProfiles4(name) {
|
|
|
21077
21187
|
name = normalizeConnectorName(name);
|
|
21078
21188
|
const seen = new Set;
|
|
21079
21189
|
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
21080
|
-
const profilesDir =
|
|
21081
|
-
if (!
|
|
21190
|
+
const profilesDir = join13(configDir, "profiles");
|
|
21191
|
+
if (!existsSync12(profilesDir))
|
|
21082
21192
|
continue;
|
|
21083
21193
|
try {
|
|
21084
21194
|
const entries = readdirSync8(profilesDir);
|
|
21085
21195
|
for (const entry of entries) {
|
|
21086
|
-
const fullPath =
|
|
21196
|
+
const fullPath = join13(profilesDir, entry);
|
|
21087
21197
|
const stat = statSync7(fullPath);
|
|
21088
21198
|
if (stat.isDirectory()) {
|
|
21089
21199
|
seen.add(entry);
|
|
@@ -21100,24 +21210,24 @@ function switchProfile(name, profile) {
|
|
|
21100
21210
|
name = normalizeConnectorName(name);
|
|
21101
21211
|
const configDir = getConnectorConfigDir2(name);
|
|
21102
21212
|
ensurePrivateDir(configDir);
|
|
21103
|
-
writePrivateText(
|
|
21213
|
+
writePrivateText(join13(configDir, "current_profile"), profile);
|
|
21104
21214
|
}
|
|
21105
21215
|
function deleteProfile2(name, profile) {
|
|
21106
21216
|
name = normalizeConnectorName(name);
|
|
21107
21217
|
if (profile === "default")
|
|
21108
21218
|
return false;
|
|
21109
21219
|
const configDir = getConnectorConfigDir2(name);
|
|
21110
|
-
const profilesDir =
|
|
21111
|
-
const profileFile =
|
|
21112
|
-
if (
|
|
21220
|
+
const profilesDir = join13(configDir, "profiles");
|
|
21221
|
+
const profileFile = join13(profilesDir, `${profile}.json`);
|
|
21222
|
+
if (existsSync12(profileFile)) {
|
|
21113
21223
|
rmSync3(profileFile);
|
|
21114
21224
|
if (getCurrentProfile2(name) === profile) {
|
|
21115
21225
|
switchProfile(name, "default");
|
|
21116
21226
|
}
|
|
21117
21227
|
return true;
|
|
21118
21228
|
}
|
|
21119
|
-
const profileDir =
|
|
21120
|
-
if (
|
|
21229
|
+
const profileDir = join13(profilesDir, profile);
|
|
21230
|
+
if (existsSync12(profileDir)) {
|
|
21121
21231
|
rmSync3(profileDir, { recursive: true });
|
|
21122
21232
|
if (getCurrentProfile2(name) === profile) {
|
|
21123
21233
|
switchProfile(name, "default");
|
|
@@ -21405,14 +21515,14 @@ __export(exports_llm, {
|
|
|
21405
21515
|
PROVIDER_DEFAULTS: () => PROVIDER_DEFAULTS,
|
|
21406
21516
|
LLMClient: () => LLMClient
|
|
21407
21517
|
});
|
|
21408
|
-
import { existsSync as
|
|
21409
|
-
import { join as
|
|
21518
|
+
import { existsSync as existsSync13, readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync8 } from "fs";
|
|
21519
|
+
import { join as join14 } from "path";
|
|
21410
21520
|
function getLlmConfigPath() {
|
|
21411
|
-
return
|
|
21521
|
+
return join14(getConnectorsHome(), "llm.json");
|
|
21412
21522
|
}
|
|
21413
21523
|
function getLlmConfig() {
|
|
21414
21524
|
const path = getLlmConfigPath();
|
|
21415
|
-
if (!
|
|
21525
|
+
if (!existsSync13(path))
|
|
21416
21526
|
return null;
|
|
21417
21527
|
try {
|
|
21418
21528
|
return JSON.parse(readFileSync7(path, "utf-8"));
|
|
@@ -21733,7 +21843,7 @@ function cronMatches(cron, d) {
|
|
|
21733
21843
|
return matches(min, d.getMinutes(), 0, 59) && matches(hour, d.getHours(), 0, 23) && matches(dom, d.getDate(), 1, 31) && matches(mon, d.getMonth() + 1, 1, 12) && matches(dow, d.getDay(), 0, 6);
|
|
21734
21844
|
}
|
|
21735
21845
|
async function runConnectorCommand(connector, command, args) {
|
|
21736
|
-
return new Promise((
|
|
21846
|
+
return new Promise((resolve2) => {
|
|
21737
21847
|
const cmdArgs = [connector, command, ...args, "--format", "json"];
|
|
21738
21848
|
const proc = spawn("connectors", ["run", ...cmdArgs], { shell: false });
|
|
21739
21849
|
let output = "";
|
|
@@ -21743,11 +21853,11 @@ async function runConnectorCommand(connector, command, args) {
|
|
|
21743
21853
|
proc.stderr.on("data", (d) => {
|
|
21744
21854
|
output += d.toString();
|
|
21745
21855
|
});
|
|
21746
|
-
proc.on("close", (code) =>
|
|
21747
|
-
proc.on("error", () =>
|
|
21856
|
+
proc.on("close", (code) => resolve2({ exitCode: code ?? 1, output }));
|
|
21857
|
+
proc.on("error", () => resolve2({ exitCode: 1, output: `Failed to spawn connectors run` }));
|
|
21748
21858
|
setTimeout(() => {
|
|
21749
21859
|
proc.kill();
|
|
21750
|
-
|
|
21860
|
+
resolve2({ exitCode: 124, output: output + `
|
|
21751
21861
|
[timeout]` });
|
|
21752
21862
|
}, 60000);
|
|
21753
21863
|
});
|
|
@@ -21815,7 +21925,7 @@ var init_scheduler = __esm(() => {
|
|
|
21815
21925
|
// src/lib/workflow-runner.ts
|
|
21816
21926
|
import { spawn as nodeSpawn } from "child_process";
|
|
21817
21927
|
async function runStep(step, previousOutput) {
|
|
21818
|
-
return new Promise((
|
|
21928
|
+
return new Promise((resolve2) => {
|
|
21819
21929
|
const args = [...step.args ?? []];
|
|
21820
21930
|
if (previousOutput && previousOutput.trim()) {
|
|
21821
21931
|
args.push("--input", previousOutput.trim().slice(0, 4096));
|
|
@@ -21829,11 +21939,11 @@ async function runStep(step, previousOutput) {
|
|
|
21829
21939
|
proc.stderr.on("data", (d) => {
|
|
21830
21940
|
output += d.toString();
|
|
21831
21941
|
});
|
|
21832
|
-
proc.on("close", (code) =>
|
|
21833
|
-
proc.on("error", () =>
|
|
21942
|
+
proc.on("close", (code) => resolve2({ exitCode: code ?? 1, output }));
|
|
21943
|
+
proc.on("error", () => resolve2({ exitCode: 1, output: "Failed to spawn connectors" }));
|
|
21834
21944
|
setTimeout(() => {
|
|
21835
21945
|
proc.kill();
|
|
21836
|
-
|
|
21946
|
+
resolve2({ exitCode: 124, output: output + `
|
|
21837
21947
|
[timeout]` });
|
|
21838
21948
|
}, 60000);
|
|
21839
21949
|
});
|
|
@@ -21881,16 +21991,16 @@ __export(exports_runner, {
|
|
|
21881
21991
|
buildEnvWithCredentials: () => buildEnvWithCredentials,
|
|
21882
21992
|
buildConnectorOperationArgs: () => buildConnectorOperationArgs
|
|
21883
21993
|
});
|
|
21884
|
-
import { existsSync as
|
|
21885
|
-
import { join as
|
|
21994
|
+
import { existsSync as existsSync14, readdirSync as readdirSync9 } from "fs";
|
|
21995
|
+
import { join as join15, dirname as dirname6 } from "path";
|
|
21886
21996
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
21887
21997
|
import { spawn as spawn2 } from "child_process";
|
|
21888
21998
|
function resolveConnectorsDir2() {
|
|
21889
|
-
const fromBin =
|
|
21890
|
-
if (
|
|
21999
|
+
const fromBin = join15(__dirname5, "..", "connectors");
|
|
22000
|
+
if (existsSync14(fromBin))
|
|
21891
22001
|
return fromBin;
|
|
21892
|
-
const fromSrc =
|
|
21893
|
-
if (
|
|
22002
|
+
const fromSrc = join15(__dirname5, "..", "..", "connectors");
|
|
22003
|
+
if (existsSync14(fromSrc))
|
|
21894
22004
|
return fromSrc;
|
|
21895
22005
|
return fromBin;
|
|
21896
22006
|
}
|
|
@@ -21958,8 +22068,8 @@ function buildEnvWithCredentials(connectorName, baseEnv) {
|
|
|
21958
22068
|
function getConnectorCliPath(name) {
|
|
21959
22069
|
const safeName = normalizeConnectorName(name).replace(/[^a-z0-9-]/g, "");
|
|
21960
22070
|
const connectorDir = getConnectorPackagePath(CONNECTORS_DIR2, safeName);
|
|
21961
|
-
const cliPath =
|
|
21962
|
-
if (
|
|
22071
|
+
const cliPath = join15(connectorDir, "src", "cli", "index.ts");
|
|
22072
|
+
if (existsSync14(cliPath))
|
|
21963
22073
|
return cliPath;
|
|
21964
22074
|
return null;
|
|
21965
22075
|
}
|
|
@@ -22153,7 +22263,7 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
|
22153
22263
|
success: false
|
|
22154
22264
|
});
|
|
22155
22265
|
}
|
|
22156
|
-
return new Promise((
|
|
22266
|
+
return new Promise((resolve2) => {
|
|
22157
22267
|
const proc = spawn2("bun", ["run", cliPath, ...args], {
|
|
22158
22268
|
timeout: timeoutMs,
|
|
22159
22269
|
env: buildEnvWithCredentials(connectorName, process.env),
|
|
@@ -22168,7 +22278,7 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
|
22168
22278
|
stderr += data.toString();
|
|
22169
22279
|
});
|
|
22170
22280
|
proc.on("close", (code) => {
|
|
22171
|
-
|
|
22281
|
+
resolve2({
|
|
22172
22282
|
stdout: stdout.trim(),
|
|
22173
22283
|
stderr: stderr.trim(),
|
|
22174
22284
|
exitCode: code ?? 1,
|
|
@@ -22176,7 +22286,7 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
|
22176
22286
|
});
|
|
22177
22287
|
});
|
|
22178
22288
|
proc.on("error", (err) => {
|
|
22179
|
-
|
|
22289
|
+
resolve2({
|
|
22180
22290
|
stdout: "",
|
|
22181
22291
|
stderr: err.message,
|
|
22182
22292
|
exitCode: 1,
|
|
@@ -28315,9 +28425,9 @@ data:
|
|
|
28315
28425
|
const initRequest = messages.find((m) => isInitializeRequest(m));
|
|
28316
28426
|
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
28317
28427
|
if (this._enableJsonResponse) {
|
|
28318
|
-
return new Promise((
|
|
28428
|
+
return new Promise((resolve2) => {
|
|
28319
28429
|
this._streamMapping.set(streamId, {
|
|
28320
|
-
resolveJson:
|
|
28430
|
+
resolveJson: resolve2,
|
|
28321
28431
|
cleanup: () => {
|
|
28322
28432
|
this._streamMapping.delete(streamId);
|
|
28323
28433
|
}
|
|
@@ -30744,7 +30854,7 @@ class Protocol {
|
|
|
30744
30854
|
return;
|
|
30745
30855
|
}
|
|
30746
30856
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1000;
|
|
30747
|
-
await new Promise((
|
|
30857
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
30748
30858
|
options?.signal?.throwIfAborted();
|
|
30749
30859
|
}
|
|
30750
30860
|
} catch (error2) {
|
|
@@ -30756,7 +30866,7 @@ class Protocol {
|
|
|
30756
30866
|
}
|
|
30757
30867
|
request(request2, resultSchema, options) {
|
|
30758
30868
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
30759
|
-
return new Promise((
|
|
30869
|
+
return new Promise((resolve2, reject) => {
|
|
30760
30870
|
const earlyReject = (error2) => {
|
|
30761
30871
|
reject(error2);
|
|
30762
30872
|
};
|
|
@@ -30834,7 +30944,7 @@ class Protocol {
|
|
|
30834
30944
|
if (!parseResult.success) {
|
|
30835
30945
|
reject(parseResult.error);
|
|
30836
30946
|
} else {
|
|
30837
|
-
|
|
30947
|
+
resolve2(parseResult.data);
|
|
30838
30948
|
}
|
|
30839
30949
|
} catch (error2) {
|
|
30840
30950
|
reject(error2);
|
|
@@ -31025,12 +31135,12 @@ class Protocol {
|
|
|
31025
31135
|
interval = task.pollInterval;
|
|
31026
31136
|
}
|
|
31027
31137
|
} catch {}
|
|
31028
|
-
return new Promise((
|
|
31138
|
+
return new Promise((resolve2, reject) => {
|
|
31029
31139
|
if (signal.aborted) {
|
|
31030
31140
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
31031
31141
|
return;
|
|
31032
31142
|
}
|
|
31033
|
-
const timeoutId = setTimeout(
|
|
31143
|
+
const timeoutId = setTimeout(resolve2, interval);
|
|
31034
31144
|
signal.addEventListener("abort", () => {
|
|
31035
31145
|
clearTimeout(timeoutId);
|
|
31036
31146
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -34015,7 +34125,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
34015
34125
|
const schOrFunc = root.refs[ref];
|
|
34016
34126
|
if (schOrFunc)
|
|
34017
34127
|
return schOrFunc;
|
|
34018
|
-
let _sch =
|
|
34128
|
+
let _sch = resolve2.call(this, root, ref);
|
|
34019
34129
|
if (_sch === undefined) {
|
|
34020
34130
|
const schema = (_a = root.localRefs) === null || _a === undefined ? undefined : _a[ref];
|
|
34021
34131
|
const { schemaId } = this.opts;
|
|
@@ -34042,7 +34152,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
34042
34152
|
function sameSchemaEnv(s1, s2) {
|
|
34043
34153
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
34044
34154
|
}
|
|
34045
|
-
function
|
|
34155
|
+
function resolve2(root, ref) {
|
|
34046
34156
|
let sch;
|
|
34047
34157
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
34048
34158
|
ref = sch;
|
|
@@ -34628,7 +34738,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
34628
34738
|
}
|
|
34629
34739
|
return uri;
|
|
34630
34740
|
}
|
|
34631
|
-
function
|
|
34741
|
+
function resolve2(baseURI, relativeURI, options) {
|
|
34632
34742
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
34633
34743
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
|
|
34634
34744
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -34913,7 +35023,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
34913
35023
|
var fastUri = {
|
|
34914
35024
|
SCHEMES,
|
|
34915
35025
|
normalize,
|
|
34916
|
-
resolve,
|
|
35026
|
+
resolve: resolve2,
|
|
34917
35027
|
resolveComponent,
|
|
34918
35028
|
equal,
|
|
34919
35029
|
serialize,
|
|
@@ -38484,7 +38594,7 @@ class McpServer {
|
|
|
38484
38594
|
let task = createTaskResult.task;
|
|
38485
38595
|
const pollInterval = task.pollInterval ?? 5000;
|
|
38486
38596
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
38487
|
-
await new Promise((
|
|
38597
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
38488
38598
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
38489
38599
|
if (!updatedTask) {
|
|
38490
38600
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -39367,8 +39477,8 @@ var init_management = __esm(() => {
|
|
|
39367
39477
|
});
|
|
39368
39478
|
|
|
39369
39479
|
// src/mcp/tools/auth.ts
|
|
39370
|
-
import { existsSync as
|
|
39371
|
-
import { join as
|
|
39480
|
+
import { existsSync as existsSync15, readFileSync as readFileSync8 } from "fs";
|
|
39481
|
+
import { join as join16 } from "path";
|
|
39372
39482
|
import { spawn as spawn3 } from "child_process";
|
|
39373
39483
|
function registerAuthTools(server, stripped) {
|
|
39374
39484
|
server.registerTool("connector_auth_status", {
|
|
@@ -39503,8 +39613,8 @@ function registerAuthTools(server, stripped) {
|
|
|
39503
39613
|
const serverPort = port || 9876;
|
|
39504
39614
|
const oauthUrl = `http://localhost:${serverPort}/oauth/${name}/start`;
|
|
39505
39615
|
if (noBrowser) {
|
|
39506
|
-
const
|
|
39507
|
-
const tokenPaths = getConnectorConfigReadDirs(name,
|
|
39616
|
+
const connectorsHome2 = getConnectorsHome();
|
|
39617
|
+
const tokenPaths = getConnectorConfigReadDirs(name, connectorsHome2).map((dir) => join16(dir, "profiles", "default", "tokens.json"));
|
|
39508
39618
|
let serverRunning = false;
|
|
39509
39619
|
try {
|
|
39510
39620
|
await fetch(`http://localhost:${serverPort}/api/connectors`);
|
|
@@ -39517,13 +39627,13 @@ function registerAuthTools(server, stripped) {
|
|
|
39517
39627
|
stdio: "ignore"
|
|
39518
39628
|
});
|
|
39519
39629
|
serverProc.unref();
|
|
39520
|
-
await new Promise((
|
|
39630
|
+
await new Promise((resolve2) => setTimeout(resolve2, 2000));
|
|
39521
39631
|
}
|
|
39522
39632
|
let attempts = 0;
|
|
39523
39633
|
const maxAttempts = 120;
|
|
39524
39634
|
while (attempts < maxAttempts) {
|
|
39525
|
-
await new Promise((
|
|
39526
|
-
if (tokenPaths.some((tokensPath) =>
|
|
39635
|
+
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
39636
|
+
if (tokenPaths.some((tokensPath) => existsSync15(tokensPath))) {
|
|
39527
39637
|
break;
|
|
39528
39638
|
}
|
|
39529
39639
|
attempts++;
|
|
@@ -39542,7 +39652,7 @@ function registerAuthTools(server, stripped) {
|
|
|
39542
39652
|
};
|
|
39543
39653
|
}
|
|
39544
39654
|
try {
|
|
39545
|
-
const tokensPath = tokenPaths.find((path) =>
|
|
39655
|
+
const tokensPath = tokenPaths.find((path) => existsSync15(path)) ?? tokenPaths[0];
|
|
39546
39656
|
const tokenData = JSON.parse(readFileSync8(tokensPath, "utf-8"));
|
|
39547
39657
|
return {
|
|
39548
39658
|
content: [{
|
|
@@ -40436,7 +40546,7 @@ var init_powershell_utils = __esm(() => {
|
|
|
40436
40546
|
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
40437
40547
|
});
|
|
40438
40548
|
|
|
40439
|
-
// ../../node_modules/.bun/wsl-utils@0.
|
|
40549
|
+
// ../../node_modules/.bun/wsl-utils@1.0.0/node_modules/wsl-utils/utilities.js
|
|
40440
40550
|
function parseMountPointFromConfig(content) {
|
|
40441
40551
|
for (const line of content.split(`
|
|
40442
40552
|
`)) {
|
|
@@ -40451,7 +40561,8 @@ function parseMountPointFromConfig(content) {
|
|
|
40451
40561
|
}
|
|
40452
40562
|
}
|
|
40453
40563
|
|
|
40454
|
-
// ../../node_modules/.bun/wsl-utils@0.
|
|
40564
|
+
// ../../node_modules/.bun/wsl-utils@1.0.0/node_modules/wsl-utils/index.js
|
|
40565
|
+
import path from "path";
|
|
40455
40566
|
import { promisify as promisify2 } from "util";
|
|
40456
40567
|
import childProcess2 from "child_process";
|
|
40457
40568
|
import fs4, { constants as fsConstants } from "fs/promises";
|
|
@@ -40472,18 +40583,33 @@ var execFile2, wslDrivesMountPoint, powerShellPathFromWsl = async () => {
|
|
|
40472
40583
|
}, wslDefaultBrowser = async () => {
|
|
40473
40584
|
const psPath = await powerShellPath2();
|
|
40474
40585
|
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
40475
|
-
const { stdout } = await executePowerShell(command, {
|
|
40586
|
+
const { stdout } = await executePowerShell(command, {
|
|
40587
|
+
powerShellPath: psPath,
|
|
40588
|
+
cwd: path.dirname(psPath)
|
|
40589
|
+
});
|
|
40476
40590
|
return stdout.trim();
|
|
40477
|
-
}, convertWslPathToWindows = async (
|
|
40478
|
-
|
|
40479
|
-
|
|
40480
|
-
|
|
40481
|
-
|
|
40482
|
-
|
|
40483
|
-
|
|
40484
|
-
|
|
40485
|
-
|
|
40591
|
+
}, isUrl = (path2) => /^[a-z]+:\/\//i.test(path2), convertWslPathToWindows = async (paths) => {
|
|
40592
|
+
const isBatch = Array.isArray(paths);
|
|
40593
|
+
const pathArray = isBatch ? paths : [paths];
|
|
40594
|
+
const indicesToConvert = [];
|
|
40595
|
+
const pathsToConvert = [];
|
|
40596
|
+
for (const [index, path2] of pathArray.entries()) {
|
|
40597
|
+
if (!isUrl(path2)) {
|
|
40598
|
+
indicesToConvert.push(index);
|
|
40599
|
+
pathsToConvert.push(path2);
|
|
40600
|
+
}
|
|
40601
|
+
}
|
|
40602
|
+
const results = [...pathArray];
|
|
40603
|
+
if (pathsToConvert.length > 0) {
|
|
40604
|
+
try {
|
|
40605
|
+
const { stdout } = await execFile2("wslpath", ["-aw", ...pathsToConvert], { encoding: "utf8" });
|
|
40606
|
+
const convertedPaths = stdout.split(/\r?\n/).filter(Boolean);
|
|
40607
|
+
for (const [index, originalIndex] of indicesToConvert.entries()) {
|
|
40608
|
+
results[originalIndex] = convertedPaths[index] ?? pathArray[originalIndex];
|
|
40609
|
+
}
|
|
40610
|
+
} catch {}
|
|
40486
40611
|
}
|
|
40612
|
+
return isBatch ? results : results[0];
|
|
40487
40613
|
};
|
|
40488
40614
|
var init_wsl_utils = __esm(() => {
|
|
40489
40615
|
init_is_wsl();
|
|
@@ -40519,6 +40645,36 @@ var init_wsl_utils = __esm(() => {
|
|
|
40519
40645
|
powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
40520
40646
|
});
|
|
40521
40647
|
|
|
40648
|
+
// ../../node_modules/.bun/powershell-utils@0.2.0/node_modules/powershell-utils/index.js
|
|
40649
|
+
import process5 from "process";
|
|
40650
|
+
import { Buffer as Buffer4 } from "buffer";
|
|
40651
|
+
import { promisify as promisify3 } from "util";
|
|
40652
|
+
import childProcess3 from "child_process";
|
|
40653
|
+
var execFile3, powerShellPath3 = () => `${process5.env.SYSTEMROOT || process5.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, argumentsPrefix, encodeCommand = (command) => Buffer4.from(command, "utf16le").toString("base64"), escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`, createArguments = (command) => [...argumentsPrefix, encodeCommand(command)], executePowerShell2 = async (command, options = {}) => {
|
|
40654
|
+
const {
|
|
40655
|
+
powerShellPath: psPath,
|
|
40656
|
+
...execFileOptions
|
|
40657
|
+
} = options;
|
|
40658
|
+
return execFile3(psPath ?? powerShellPath3(), createArguments(command), {
|
|
40659
|
+
encoding: "utf8",
|
|
40660
|
+
...execFileOptions
|
|
40661
|
+
});
|
|
40662
|
+
};
|
|
40663
|
+
var init_powershell_utils2 = __esm(() => {
|
|
40664
|
+
execFile3 = promisify3(childProcess3.execFile);
|
|
40665
|
+
argumentsPrefix = [
|
|
40666
|
+
"-NoProfile",
|
|
40667
|
+
"-NonInteractive",
|
|
40668
|
+
"-ExecutionPolicy",
|
|
40669
|
+
"Bypass",
|
|
40670
|
+
"-EncodedCommand"
|
|
40671
|
+
];
|
|
40672
|
+
executePowerShell2.argumentsPrefix = argumentsPrefix;
|
|
40673
|
+
executePowerShell2.encodeCommand = encodeCommand;
|
|
40674
|
+
executePowerShell2.escapeArgument = escapeArgument;
|
|
40675
|
+
executePowerShell2.createArguments = createArguments;
|
|
40676
|
+
});
|
|
40677
|
+
|
|
40522
40678
|
// ../../node_modules/.bun/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
40523
40679
|
function defineLazyProperty(object4, propertyName, valueGetter) {
|
|
40524
40680
|
const define = (value) => Object.defineProperty(object4, propertyName, { value, enumerable: true, writable: true });
|
|
@@ -40538,11 +40694,11 @@ function defineLazyProperty(object4, propertyName, valueGetter) {
|
|
|
40538
40694
|
}
|
|
40539
40695
|
|
|
40540
40696
|
// ../../node_modules/.bun/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
40541
|
-
import { promisify as
|
|
40542
|
-
import
|
|
40543
|
-
import { execFile as
|
|
40697
|
+
import { promisify as promisify4 } from "util";
|
|
40698
|
+
import process6 from "process";
|
|
40699
|
+
import { execFile as execFile4 } from "child_process";
|
|
40544
40700
|
async function defaultBrowserId() {
|
|
40545
|
-
if (
|
|
40701
|
+
if (process6.platform !== "darwin") {
|
|
40546
40702
|
throw new Error("macOS only");
|
|
40547
40703
|
}
|
|
40548
40704
|
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
@@ -40555,15 +40711,15 @@ async function defaultBrowserId() {
|
|
|
40555
40711
|
}
|
|
40556
40712
|
var execFileAsync;
|
|
40557
40713
|
var init_default_browser_id = __esm(() => {
|
|
40558
|
-
execFileAsync =
|
|
40714
|
+
execFileAsync = promisify4(execFile4);
|
|
40559
40715
|
});
|
|
40560
40716
|
|
|
40561
40717
|
// ../../node_modules/.bun/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
40562
|
-
import
|
|
40563
|
-
import { promisify as
|
|
40564
|
-
import { execFile as
|
|
40718
|
+
import process7 from "process";
|
|
40719
|
+
import { promisify as promisify5 } from "util";
|
|
40720
|
+
import { execFile as execFile5, execFileSync } from "child_process";
|
|
40565
40721
|
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
40566
|
-
if (
|
|
40722
|
+
if (process7.platform !== "darwin") {
|
|
40567
40723
|
throw new Error("macOS only");
|
|
40568
40724
|
}
|
|
40569
40725
|
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
@@ -40576,7 +40732,7 @@ async function runAppleScript(script, { humanReadableOutput = true, signal } = {
|
|
|
40576
40732
|
}
|
|
40577
40733
|
var execFileAsync2;
|
|
40578
40734
|
var init_run_applescript = __esm(() => {
|
|
40579
|
-
execFileAsync2 =
|
|
40735
|
+
execFileAsync2 = promisify5(execFile5);
|
|
40580
40736
|
});
|
|
40581
40737
|
|
|
40582
40738
|
// ../../node_modules/.bun/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
@@ -40588,11 +40744,13 @@ var init_bundle_name = __esm(() => {
|
|
|
40588
40744
|
init_run_applescript();
|
|
40589
40745
|
});
|
|
40590
40746
|
|
|
40591
|
-
// ../../node_modules/.bun/default-browser@5.5.
|
|
40592
|
-
import
|
|
40593
|
-
import {
|
|
40747
|
+
// ../../node_modules/.bun/default-browser@5.5.1/node_modules/default-browser/windows.js
|
|
40748
|
+
import process8 from "process";
|
|
40749
|
+
import { promisify as promisify6 } from "util";
|
|
40750
|
+
import { execFile as execFile6 } from "child_process";
|
|
40594
40751
|
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
40595
|
-
const {
|
|
40752
|
+
const regPath = `${process8.env.SYSTEMROOT ?? process8.env.windir ?? "C:\\Windows"}\\System32\\reg.exe`;
|
|
40753
|
+
const { stdout } = await _execFileAsync(regPath, [
|
|
40596
40754
|
"QUERY",
|
|
40597
40755
|
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
40598
40756
|
"/v",
|
|
@@ -40611,7 +40769,7 @@ async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
|
40611
40769
|
}
|
|
40612
40770
|
var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
|
|
40613
40771
|
var init_windows = __esm(() => {
|
|
40614
|
-
execFileAsync3 =
|
|
40772
|
+
execFileAsync3 = promisify6(execFile6);
|
|
40615
40773
|
windowsBrowserProgIds = {
|
|
40616
40774
|
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
40617
40775
|
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
@@ -40635,23 +40793,23 @@ var init_windows = __esm(() => {
|
|
|
40635
40793
|
};
|
|
40636
40794
|
});
|
|
40637
40795
|
|
|
40638
|
-
// ../../node_modules/.bun/default-browser@5.5.
|
|
40639
|
-
import { promisify as
|
|
40640
|
-
import
|
|
40641
|
-
import { execFile as
|
|
40796
|
+
// ../../node_modules/.bun/default-browser@5.5.1/node_modules/default-browser/index.js
|
|
40797
|
+
import { promisify as promisify7 } from "util";
|
|
40798
|
+
import process9 from "process";
|
|
40799
|
+
import { execFile as execFile7 } from "child_process";
|
|
40642
40800
|
async function defaultBrowser2() {
|
|
40643
|
-
if (
|
|
40801
|
+
if (process9.platform === "darwin") {
|
|
40644
40802
|
const id = await defaultBrowserId();
|
|
40645
40803
|
const name = await bundleName(id);
|
|
40646
40804
|
return { name, id };
|
|
40647
40805
|
}
|
|
40648
|
-
if (
|
|
40806
|
+
if (process9.platform === "linux") {
|
|
40649
40807
|
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
40650
40808
|
const id = stdout.trim();
|
|
40651
40809
|
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
40652
40810
|
return { name, id };
|
|
40653
40811
|
}
|
|
40654
|
-
if (
|
|
40812
|
+
if (process9.platform === "win32") {
|
|
40655
40813
|
return defaultBrowser();
|
|
40656
40814
|
}
|
|
40657
40815
|
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
@@ -40662,22 +40820,22 @@ var init_default_browser = __esm(() => {
|
|
|
40662
40820
|
init_bundle_name();
|
|
40663
40821
|
init_windows();
|
|
40664
40822
|
init_windows();
|
|
40665
|
-
execFileAsync4 =
|
|
40823
|
+
execFileAsync4 = promisify7(execFile7);
|
|
40666
40824
|
});
|
|
40667
40825
|
|
|
40668
40826
|
// ../../node_modules/.bun/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
|
|
40669
|
-
import
|
|
40827
|
+
import process10 from "process";
|
|
40670
40828
|
var isInSsh, is_in_ssh_default;
|
|
40671
40829
|
var init_is_in_ssh = __esm(() => {
|
|
40672
|
-
isInSsh = Boolean(
|
|
40830
|
+
isInSsh = Boolean(process10.env.SSH_CONNECTION || process10.env.SSH_CLIENT || process10.env.SSH_TTY);
|
|
40673
40831
|
is_in_ssh_default = isInSsh;
|
|
40674
40832
|
});
|
|
40675
40833
|
|
|
40676
|
-
// ../../node_modules/.bun/open@11.0.
|
|
40677
|
-
import
|
|
40678
|
-
import
|
|
40834
|
+
// ../../node_modules/.bun/open@11.0.1/node_modules/open/index.js
|
|
40835
|
+
import process11 from "process";
|
|
40836
|
+
import path2 from "path";
|
|
40679
40837
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
40680
|
-
import
|
|
40838
|
+
import childProcess4 from "child_process";
|
|
40681
40839
|
import fs5, { constants as fsConstants2 } from "fs/promises";
|
|
40682
40840
|
function detectArchBinary(binary) {
|
|
40683
40841
|
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
@@ -40808,7 +40966,7 @@ var fallbackAttemptSymbol, __dirname6, localXdgOpenPath, platform, arch, tryEach
|
|
|
40808
40966
|
}
|
|
40809
40967
|
} else if (platform === "win32" || shouldUseWindowsInWsl) {
|
|
40810
40968
|
command = await powerShellPath2();
|
|
40811
|
-
cliArguments.push(...
|
|
40969
|
+
cliArguments.push(...executePowerShell2.argumentsPrefix);
|
|
40812
40970
|
if (!is_wsl_default) {
|
|
40813
40971
|
childProcessOptions.windowsVerbatimArguments = true;
|
|
40814
40972
|
}
|
|
@@ -40820,21 +40978,24 @@ var fallbackAttemptSymbol, __dirname6, localXdgOpenPath, platform, arch, tryEach
|
|
|
40820
40978
|
encodedArguments.push("-Wait");
|
|
40821
40979
|
}
|
|
40822
40980
|
if (app) {
|
|
40823
|
-
encodedArguments.push(
|
|
40981
|
+
encodedArguments.push(executePowerShell2.escapeArgument(app));
|
|
40824
40982
|
if (options.target) {
|
|
40825
40983
|
appArguments.push(options.target);
|
|
40826
40984
|
}
|
|
40827
40985
|
} else if (options.target) {
|
|
40828
|
-
encodedArguments.push(
|
|
40986
|
+
encodedArguments.push(executePowerShell2.escapeArgument(options.target));
|
|
40829
40987
|
}
|
|
40830
40988
|
if (appArguments.length > 0) {
|
|
40831
|
-
appArguments = appArguments.map((argument) =>
|
|
40989
|
+
appArguments = appArguments.map((argument) => executePowerShell2.escapeArgument(argument));
|
|
40832
40990
|
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
40833
40991
|
}
|
|
40834
|
-
options.target =
|
|
40992
|
+
options.target = executePowerShell2.encodeCommand(encodedArguments.join(" "));
|
|
40835
40993
|
if (!options.wait) {
|
|
40836
40994
|
childProcessOptions.stdio = "ignore";
|
|
40837
40995
|
}
|
|
40996
|
+
if (is_wsl_default) {
|
|
40997
|
+
childProcessOptions.cwd = path2.dirname(command);
|
|
40998
|
+
}
|
|
40838
40999
|
} else {
|
|
40839
41000
|
if (app) {
|
|
40840
41001
|
command = app;
|
|
@@ -40845,7 +41006,7 @@ var fallbackAttemptSymbol, __dirname6, localXdgOpenPath, platform, arch, tryEach
|
|
|
40845
41006
|
await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
40846
41007
|
exeLocalXdgOpen = true;
|
|
40847
41008
|
} catch {}
|
|
40848
|
-
const useSystemXdgOpen =
|
|
41009
|
+
const useSystemXdgOpen = process11.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
40849
41010
|
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
40850
41011
|
}
|
|
40851
41012
|
if (appArguments.length > 0) {
|
|
@@ -40862,21 +41023,21 @@ var fallbackAttemptSymbol, __dirname6, localXdgOpenPath, platform, arch, tryEach
|
|
|
40862
41023
|
if (options.target) {
|
|
40863
41024
|
cliArguments.push(options.target);
|
|
40864
41025
|
}
|
|
40865
|
-
const subprocess =
|
|
41026
|
+
const subprocess = childProcess4.spawn(command, cliArguments, childProcessOptions);
|
|
40866
41027
|
if (options.wait) {
|
|
40867
|
-
return new Promise((
|
|
41028
|
+
return new Promise((resolve2, reject) => {
|
|
40868
41029
|
subprocess.once("error", reject);
|
|
40869
41030
|
subprocess.once("close", (exitCode) => {
|
|
40870
41031
|
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
40871
41032
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
40872
41033
|
return;
|
|
40873
41034
|
}
|
|
40874
|
-
|
|
41035
|
+
resolve2(subprocess);
|
|
40875
41036
|
});
|
|
40876
41037
|
});
|
|
40877
41038
|
}
|
|
40878
41039
|
if (isFallbackAttempt) {
|
|
40879
|
-
return new Promise((
|
|
41040
|
+
return new Promise((resolve2, reject) => {
|
|
40880
41041
|
subprocess.once("error", reject);
|
|
40881
41042
|
subprocess.once("spawn", () => {
|
|
40882
41043
|
subprocess.once("close", (exitCode) => {
|
|
@@ -40886,17 +41047,17 @@ var fallbackAttemptSymbol, __dirname6, localXdgOpenPath, platform, arch, tryEach
|
|
|
40886
41047
|
return;
|
|
40887
41048
|
}
|
|
40888
41049
|
subprocess.unref();
|
|
40889
|
-
|
|
41050
|
+
resolve2(subprocess);
|
|
40890
41051
|
});
|
|
40891
41052
|
});
|
|
40892
41053
|
});
|
|
40893
41054
|
}
|
|
40894
41055
|
subprocess.unref();
|
|
40895
|
-
return new Promise((
|
|
41056
|
+
return new Promise((resolve2, reject) => {
|
|
40896
41057
|
subprocess.once("error", reject);
|
|
40897
41058
|
subprocess.once("spawn", () => {
|
|
40898
41059
|
subprocess.off("error", reject);
|
|
40899
|
-
|
|
41060
|
+
resolve2(subprocess);
|
|
40900
41061
|
});
|
|
40901
41062
|
});
|
|
40902
41063
|
}, open = (target, options) => {
|
|
@@ -40910,14 +41071,14 @@ var fallbackAttemptSymbol, __dirname6, localXdgOpenPath, platform, arch, tryEach
|
|
|
40910
41071
|
}, apps, open_default;
|
|
40911
41072
|
var init_open = __esm(() => {
|
|
40912
41073
|
init_wsl_utils();
|
|
40913
|
-
|
|
41074
|
+
init_powershell_utils2();
|
|
40914
41075
|
init_default_browser();
|
|
40915
41076
|
init_is_inside_container();
|
|
40916
41077
|
init_is_in_ssh();
|
|
40917
41078
|
fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
40918
|
-
__dirname6 = import.meta.url ?
|
|
40919
|
-
localXdgOpenPath =
|
|
40920
|
-
({ platform, arch } =
|
|
41079
|
+
__dirname6 = import.meta.url ? path2.dirname(fileURLToPath6(import.meta.url)) : "";
|
|
41080
|
+
localXdgOpenPath = path2.join(__dirname6, "xdg-open");
|
|
41081
|
+
({ platform, arch } = process11);
|
|
40921
41082
|
apps = {
|
|
40922
41083
|
browser: "browser",
|
|
40923
41084
|
browserPrivate: "browserPrivate"
|
|
@@ -40984,8 +41145,8 @@ var exports_serve = {};
|
|
|
40984
41145
|
__export(exports_serve, {
|
|
40985
41146
|
startServer: () => startServer
|
|
40986
41147
|
});
|
|
40987
|
-
import { existsSync as
|
|
40988
|
-
import { join as
|
|
41148
|
+
import { existsSync as existsSync16, readdirSync as readdirSync10, readFileSync as readFileSync9, writeFileSync as writeFileSync7, mkdirSync as mkdirSync9 } from "fs";
|
|
41149
|
+
import { join as join17, dirname as dirname7, extname, basename as basename3, relative as relative2, resolve as resolve2, sep } from "path";
|
|
40989
41150
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
40990
41151
|
function logActivity(action, connector, detail) {
|
|
40991
41152
|
activityLog.unshift({ action, connector, timestamp: Date.now(), detail });
|
|
@@ -40997,20 +41158,20 @@ function resolveDashboardDir() {
|
|
|
40997
41158
|
const candidates = [];
|
|
40998
41159
|
try {
|
|
40999
41160
|
const scriptDir = dirname7(fileURLToPath7(import.meta.url));
|
|
41000
|
-
candidates.push(
|
|
41001
|
-
candidates.push(
|
|
41161
|
+
candidates.push(join17(scriptDir, "..", "dashboard", "dist"));
|
|
41162
|
+
candidates.push(join17(scriptDir, "..", "..", "dashboard", "dist"));
|
|
41002
41163
|
} catch {}
|
|
41003
41164
|
if (process.argv[1]) {
|
|
41004
41165
|
const mainDir = dirname7(process.argv[1]);
|
|
41005
|
-
candidates.push(
|
|
41006
|
-
candidates.push(
|
|
41166
|
+
candidates.push(join17(mainDir, "..", "dashboard", "dist"));
|
|
41167
|
+
candidates.push(join17(mainDir, "..", "..", "dashboard", "dist"));
|
|
41007
41168
|
}
|
|
41008
|
-
candidates.push(
|
|
41169
|
+
candidates.push(join17(process.cwd(), "dashboard", "dist"));
|
|
41009
41170
|
for (const candidate of candidates) {
|
|
41010
|
-
if (
|
|
41171
|
+
if (existsSync16(candidate))
|
|
41011
41172
|
return candidate;
|
|
41012
41173
|
}
|
|
41013
|
-
return
|
|
41174
|
+
return join17(process.cwd(), "dashboard", "dist");
|
|
41014
41175
|
}
|
|
41015
41176
|
function json(data, status = 200, port) {
|
|
41016
41177
|
return new Response(JSON.stringify(data), {
|
|
@@ -41092,7 +41253,7 @@ function oauthPage(type, title, message, hint, extra) {
|
|
|
41092
41253
|
</body></html>`;
|
|
41093
41254
|
}
|
|
41094
41255
|
function serveStaticFile(filePath) {
|
|
41095
|
-
if (!
|
|
41256
|
+
if (!existsSync16(filePath))
|
|
41096
41257
|
return null;
|
|
41097
41258
|
const ext = extname(filePath);
|
|
41098
41259
|
const contentType2 = MIME_TYPES[ext] || "application/octet-stream";
|
|
@@ -41129,7 +41290,7 @@ async function startServer(requestedPort, options) {
|
|
|
41129
41290
|
const strict = options?.strict ?? false;
|
|
41130
41291
|
loadConnectorVersions();
|
|
41131
41292
|
const dashboardDir = resolveDashboardDir();
|
|
41132
|
-
const dashboardExists =
|
|
41293
|
+
const dashboardExists = existsSync16(dashboardDir);
|
|
41133
41294
|
if (!dashboardExists) {
|
|
41134
41295
|
console.error(`
|
|
41135
41296
|
Dashboard not found at: ${dashboardDir}`);
|
|
@@ -41150,12 +41311,12 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
41150
41311
|
port,
|
|
41151
41312
|
async fetch(req) {
|
|
41152
41313
|
const url2 = new URL(req.url);
|
|
41153
|
-
const
|
|
41314
|
+
const path3 = url2.pathname;
|
|
41154
41315
|
const method = req.method;
|
|
41155
41316
|
const mcpResponse = await handleMcpHttpRequest(req);
|
|
41156
41317
|
if (mcpResponse)
|
|
41157
41318
|
return mcpResponse;
|
|
41158
|
-
if (
|
|
41319
|
+
if (path3 === "/api/connectors" && method === "GET") {
|
|
41159
41320
|
const compact = url2.searchParams.get("compact") === "true";
|
|
41160
41321
|
const fieldsParam = url2.searchParams.get("fields");
|
|
41161
41322
|
const fields = fieldsParam ? new Set(fieldsParam.split(",").map((f) => f.trim())) : null;
|
|
@@ -41175,7 +41336,7 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
41175
41336
|
}
|
|
41176
41337
|
return jsonStripped(data, 200, port);
|
|
41177
41338
|
}
|
|
41178
|
-
if (
|
|
41339
|
+
if (path3 === "/api/connectors/manifest" && method === "GET") {
|
|
41179
41340
|
const connectorNames = url2.searchParams.get("connectors")?.split(",").map((name) => name.trim()).filter(Boolean);
|
|
41180
41341
|
const includeOperations = url2.searchParams.get("includeOperations") === "true";
|
|
41181
41342
|
const manifest = await getConnectorCapabilityManifest({
|
|
@@ -41184,7 +41345,7 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
41184
41345
|
});
|
|
41185
41346
|
return json(manifest, 200, port);
|
|
41186
41347
|
}
|
|
41187
|
-
const singleMatch =
|
|
41348
|
+
const singleMatch = path3.match(/^\/api\/connectors\/([^/]+)$/);
|
|
41188
41349
|
if (singleMatch && method === "GET") {
|
|
41189
41350
|
const name = singleMatch[1];
|
|
41190
41351
|
if (!isValidConnectorName(name))
|
|
@@ -41204,7 +41365,7 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
41204
41365
|
overview: docs?.overview || null
|
|
41205
41366
|
}, 200, port);
|
|
41206
41367
|
}
|
|
41207
|
-
const operationsMatch =
|
|
41368
|
+
const operationsMatch = path3.match(/^\/api\/connectors\/([^/]+)\/operations$/);
|
|
41208
41369
|
if (operationsMatch && method === "GET") {
|
|
41209
41370
|
const name = operationsMatch[1];
|
|
41210
41371
|
if (!isValidConnectorName(name))
|
|
@@ -41225,7 +41386,7 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
41225
41386
|
helpText: ops.helpText
|
|
41226
41387
|
}, 200, port);
|
|
41227
41388
|
}
|
|
41228
|
-
const operationHelpMatch =
|
|
41389
|
+
const operationHelpMatch = path3.match(/^\/api\/connectors\/([^/]+)\/operations\/([^/]+)$/);
|
|
41229
41390
|
if (operationHelpMatch && method === "GET") {
|
|
41230
41391
|
const name = operationHelpMatch[1];
|
|
41231
41392
|
const command = decodeURIComponent(operationHelpMatch[2]);
|
|
@@ -41240,7 +41401,7 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
41240
41401
|
const help = await getConnectorCommandHelp(name, command);
|
|
41241
41402
|
return json({ connector: name, displayName: meta.displayName, command, help }, 200, port);
|
|
41242
41403
|
}
|
|
41243
|
-
const operationRunMatch =
|
|
41404
|
+
const operationRunMatch = path3.match(/^\/api\/connectors\/([^/]+)\/operations\/run$/);
|
|
41244
41405
|
if (operationRunMatch && method === "POST") {
|
|
41245
41406
|
const name = operationRunMatch[1];
|
|
41246
41407
|
if (!isValidConnectorName(name))
|
|
@@ -41304,7 +41465,7 @@ ${result.stderr}`;
|
|
|
41304
41465
|
}, 500, port);
|
|
41305
41466
|
}
|
|
41306
41467
|
}
|
|
41307
|
-
const keyMatch =
|
|
41468
|
+
const keyMatch = path3.match(/^\/api\/connectors\/([^/]+)\/key$/);
|
|
41308
41469
|
if (keyMatch && method === "POST") {
|
|
41309
41470
|
const name = keyMatch[1];
|
|
41310
41471
|
if (!isValidConnectorName(name))
|
|
@@ -41323,7 +41484,7 @@ ${result.stderr}`;
|
|
|
41323
41484
|
return json({ error: e instanceof Error ? e.message : "Failed to save key" }, 500, port);
|
|
41324
41485
|
}
|
|
41325
41486
|
}
|
|
41326
|
-
const refreshMatch =
|
|
41487
|
+
const refreshMatch = path3.match(/^\/api\/connectors\/([^/]+)\/refresh$/);
|
|
41327
41488
|
if (refreshMatch && method === "POST") {
|
|
41328
41489
|
const name = refreshMatch[1];
|
|
41329
41490
|
if (!isValidConnectorName(name))
|
|
@@ -41336,7 +41497,7 @@ ${result.stderr}`;
|
|
|
41336
41497
|
return json({ success: false, error: e instanceof Error ? e.message : "Failed to refresh" }, 500, port);
|
|
41337
41498
|
}
|
|
41338
41499
|
}
|
|
41339
|
-
const installMatch =
|
|
41500
|
+
const installMatch = path3.match(/^\/api\/connectors\/([^/]+)\/install$/);
|
|
41340
41501
|
if (installMatch && method === "POST") {
|
|
41341
41502
|
const name = installMatch[1];
|
|
41342
41503
|
if (!isValidConnectorName(name))
|
|
@@ -41355,7 +41516,7 @@ ${result.stderr}`;
|
|
|
41355
41516
|
return json({ error: e instanceof Error ? e.message : "Failed to install connector" }, 500, port);
|
|
41356
41517
|
}
|
|
41357
41518
|
}
|
|
41358
|
-
const uninstallMatch =
|
|
41519
|
+
const uninstallMatch = path3.match(/^\/api\/connectors\/([^/]+)\/uninstall$/);
|
|
41359
41520
|
if (uninstallMatch && method === "POST") {
|
|
41360
41521
|
const name = uninstallMatch[1];
|
|
41361
41522
|
if (!isValidConnectorName(name))
|
|
@@ -41371,7 +41532,7 @@ ${result.stderr}`;
|
|
|
41371
41532
|
return json({ error: e instanceof Error ? e.message : "Failed to uninstall connector" }, 500, port);
|
|
41372
41533
|
}
|
|
41373
41534
|
}
|
|
41374
|
-
if (
|
|
41535
|
+
if (path3 === "/api/update" && method === "POST") {
|
|
41375
41536
|
try {
|
|
41376
41537
|
const installed = getInstalledConnectors();
|
|
41377
41538
|
if (installed.length === 0) {
|
|
@@ -41387,10 +41548,10 @@ ${result.stderr}`;
|
|
|
41387
41548
|
return json({ error: e instanceof Error ? e.message : "Failed to update" }, 500, port);
|
|
41388
41549
|
}
|
|
41389
41550
|
}
|
|
41390
|
-
if (
|
|
41551
|
+
if (path3 === "/api/activity" && method === "GET") {
|
|
41391
41552
|
return json(activityLog, 200, port);
|
|
41392
41553
|
}
|
|
41393
|
-
if (
|
|
41554
|
+
if (path3 === "/api/hot" && method === "GET") {
|
|
41394
41555
|
const { getTopConnectors: getTopConnectors2 } = await Promise.resolve().then(() => (init_usage(), exports_usage));
|
|
41395
41556
|
const { getPromotedConnectors: getPromotedConnectors2 } = await Promise.resolve().then(() => (init_promotions(), exports_promotions));
|
|
41396
41557
|
const limit = parseInt(url2.searchParams.get("limit") || "10", 10);
|
|
@@ -41400,7 +41561,7 @@ ${result.stderr}`;
|
|
|
41400
41561
|
const promoted = new Set(getPromotedConnectors2(db));
|
|
41401
41562
|
return json(top.map((t) => ({ ...t, promoted: promoted.has(t.connector) })), 200, port);
|
|
41402
41563
|
}
|
|
41403
|
-
const promoteMatch =
|
|
41564
|
+
const promoteMatch = path3.match(/^\/api\/connectors\/([^/]+)\/promote$/);
|
|
41404
41565
|
if (promoteMatch && method === "POST") {
|
|
41405
41566
|
const name = promoteMatch[1];
|
|
41406
41567
|
if (!getConnector(name))
|
|
@@ -41414,13 +41575,13 @@ ${result.stderr}`;
|
|
|
41414
41575
|
const removed = demoteConnector2(promoteMatch[1], getDatabase3());
|
|
41415
41576
|
return json({ success: removed, connector: promoteMatch[1] }, 200, port);
|
|
41416
41577
|
}
|
|
41417
|
-
if (
|
|
41578
|
+
if (path3 === "/api/llm" && method === "GET") {
|
|
41418
41579
|
const config2 = getLlmConfig();
|
|
41419
41580
|
if (!config2)
|
|
41420
41581
|
return json({ configured: false }, 200, port);
|
|
41421
41582
|
return json({ configured: true, provider: config2.provider, model: config2.model, key: maskKey(config2.api_key), strip: config2.strip }, 200, port);
|
|
41422
41583
|
}
|
|
41423
|
-
if (
|
|
41584
|
+
if (path3 === "/api/llm" && method === "POST") {
|
|
41424
41585
|
const body = await req.json().catch(() => ({}));
|
|
41425
41586
|
const validProviders = ["cerebras", "groq", "openai", "anthropic"];
|
|
41426
41587
|
const provider = body.provider;
|
|
@@ -41434,7 +41595,7 @@ ${result.stderr}`;
|
|
|
41434
41595
|
saveLlmConfig({ provider, model, api_key, strip });
|
|
41435
41596
|
return json({ success: true, provider, model, strip }, 200, port);
|
|
41436
41597
|
}
|
|
41437
|
-
if (
|
|
41598
|
+
if (path3 === "/api/llm/test" && method === "POST") {
|
|
41438
41599
|
const config2 = getLlmConfig();
|
|
41439
41600
|
if (!config2)
|
|
41440
41601
|
return json({ error: "No LLM configured" }, 400, port);
|
|
@@ -41446,17 +41607,17 @@ ${result.stderr}`;
|
|
|
41446
41607
|
return json({ success: false, error: e instanceof Error ? e.message : String(e) }, 500, port);
|
|
41447
41608
|
}
|
|
41448
41609
|
}
|
|
41449
|
-
if (
|
|
41610
|
+
if (path3 === "/api/jobs" && method === "GET") {
|
|
41450
41611
|
return json(listJobs(getDatabase3()), 200, port);
|
|
41451
41612
|
}
|
|
41452
|
-
if (
|
|
41613
|
+
if (path3 === "/api/jobs" && method === "POST") {
|
|
41453
41614
|
const body = await req.json().catch(() => ({}));
|
|
41454
41615
|
if (!body.name || !body.connector || !body.command || !body.cron)
|
|
41455
41616
|
return json({ error: "name, connector, command, cron required" }, 400, port);
|
|
41456
41617
|
const job = createJob({ name: body.name, connector: body.connector, command: body.command, args: body.args ?? [], cron: body.cron, strip: !!body.strip }, getDatabase3());
|
|
41457
41618
|
return json(job, 201, port);
|
|
41458
41619
|
}
|
|
41459
|
-
const jobMatch =
|
|
41620
|
+
const jobMatch = path3.match(/^\/api\/jobs\/([^/]+)$/);
|
|
41460
41621
|
if (jobMatch) {
|
|
41461
41622
|
const db = getDatabase3();
|
|
41462
41623
|
const job = getJobByName(jobMatch[1]) ?? getDatabase3().query("SELECT * FROM connector_jobs WHERE id = ?").get(jobMatch[1]);
|
|
@@ -41478,7 +41639,7 @@ ${result.stderr}`;
|
|
|
41478
41639
|
return json(updated, 200, port);
|
|
41479
41640
|
}
|
|
41480
41641
|
}
|
|
41481
|
-
const jobRunMatch =
|
|
41642
|
+
const jobRunMatch = path3.match(/^\/api\/jobs\/([^/]+)\/run$/);
|
|
41482
41643
|
if (jobRunMatch && method === "POST") {
|
|
41483
41644
|
const db = getDatabase3();
|
|
41484
41645
|
const job = getJobByName(jobRunMatch[1], db);
|
|
@@ -41487,17 +41648,17 @@ ${result.stderr}`;
|
|
|
41487
41648
|
const result = await triggerJob(job, db);
|
|
41488
41649
|
return json(result, 200, port);
|
|
41489
41650
|
}
|
|
41490
|
-
if (
|
|
41651
|
+
if (path3 === "/api/workflows" && method === "GET") {
|
|
41491
41652
|
return json(listWorkflows(getDatabase3()), 200, port);
|
|
41492
41653
|
}
|
|
41493
|
-
if (
|
|
41654
|
+
if (path3 === "/api/workflows" && method === "POST") {
|
|
41494
41655
|
const body = await req.json().catch(() => ({}));
|
|
41495
41656
|
if (!body.name || !body.steps)
|
|
41496
41657
|
return json({ error: "name and steps required" }, 400, port);
|
|
41497
41658
|
const wf = createWorkflow({ name: body.name, steps: body.steps }, getDatabase3());
|
|
41498
41659
|
return json(wf, 201, port);
|
|
41499
41660
|
}
|
|
41500
|
-
const wfMatch =
|
|
41661
|
+
const wfMatch = path3.match(/^\/api\/workflows\/([^/]+)$/);
|
|
41501
41662
|
if (wfMatch) {
|
|
41502
41663
|
const db = getDatabase3();
|
|
41503
41664
|
const wf = getWorkflowByName(wfMatch[1], db);
|
|
@@ -41510,7 +41671,7 @@ ${result.stderr}`;
|
|
|
41510
41671
|
return json({ success: true }, 200, port);
|
|
41511
41672
|
}
|
|
41512
41673
|
}
|
|
41513
|
-
const wfRunMatch =
|
|
41674
|
+
const wfRunMatch = path3.match(/^\/api\/workflows\/([^/]+)\/run$/);
|
|
41514
41675
|
if (wfRunMatch && method === "POST") {
|
|
41515
41676
|
const wf = getWorkflowByName(wfRunMatch[1], getDatabase3());
|
|
41516
41677
|
if (!wf)
|
|
@@ -41518,10 +41679,10 @@ ${result.stderr}`;
|
|
|
41518
41679
|
const result = await runWorkflow(wf);
|
|
41519
41680
|
return json(result, 200, port);
|
|
41520
41681
|
}
|
|
41521
|
-
if (
|
|
41682
|
+
if (path3 === "/api/agents" && method === "GET") {
|
|
41522
41683
|
return json(listAgents(), 200, port);
|
|
41523
41684
|
}
|
|
41524
|
-
if (
|
|
41685
|
+
if (path3 === "/api/agents/register" && method === "POST") {
|
|
41525
41686
|
const body = await req.json().catch(() => ({}));
|
|
41526
41687
|
const name = typeof body.name === "string" ? body.name : null;
|
|
41527
41688
|
if (!name)
|
|
@@ -41535,15 +41696,15 @@ ${result.stderr}`;
|
|
|
41535
41696
|
return json(result, 409, port);
|
|
41536
41697
|
return json(result, 200, port);
|
|
41537
41698
|
}
|
|
41538
|
-
if (
|
|
41539
|
-
const agentName =
|
|
41699
|
+
if (path3.startsWith("/api/agents/") && method === "DELETE") {
|
|
41700
|
+
const agentName = path3.slice("/api/agents/".length);
|
|
41540
41701
|
const agent = getAgentByName(agentName);
|
|
41541
41702
|
if (!agent)
|
|
41542
41703
|
return json({ error: "Agent not found" }, 404, port);
|
|
41543
41704
|
deleteAgent(agent.id);
|
|
41544
41705
|
return json({ success: true }, 200, port);
|
|
41545
41706
|
}
|
|
41546
|
-
const rateMatch =
|
|
41707
|
+
const rateMatch = path3.match(/^\/api\/rate\/([^/]+)\/([^/]+)$/);
|
|
41547
41708
|
if (rateMatch && method === "GET") {
|
|
41548
41709
|
const [, agentId, connector] = rateMatch;
|
|
41549
41710
|
const limit = parseInt(url2.searchParams.get("limit") || "60", 10);
|
|
@@ -41551,7 +41712,7 @@ ${result.stderr}`;
|
|
|
41551
41712
|
const result = consume ? checkRateBudget(agentId, connector, limit) : getRateBudget(agentId, connector, limit);
|
|
41552
41713
|
return json(result, 200, port);
|
|
41553
41714
|
}
|
|
41554
|
-
const profilesMatch =
|
|
41715
|
+
const profilesMatch = path3.match(/^\/api\/connectors\/([^/]+)\/profiles$/);
|
|
41555
41716
|
if (profilesMatch && method === "GET") {
|
|
41556
41717
|
const name = profilesMatch[1];
|
|
41557
41718
|
if (!isValidConnectorName(name))
|
|
@@ -41560,8 +41721,8 @@ ${result.stderr}`;
|
|
|
41560
41721
|
const profiles = listProfiles4(name);
|
|
41561
41722
|
let current = "default";
|
|
41562
41723
|
for (const configDir of getConnectorConfigReadDirs(name)) {
|
|
41563
|
-
const currentProfileFile =
|
|
41564
|
-
if (
|
|
41724
|
+
const currentProfileFile = join17(configDir, "current_profile");
|
|
41725
|
+
if (existsSync16(currentProfileFile)) {
|
|
41565
41726
|
try {
|
|
41566
41727
|
current = readFileSync9(currentProfileFile, "utf-8").trim() || "default";
|
|
41567
41728
|
} catch {}
|
|
@@ -41573,7 +41734,7 @@ ${result.stderr}`;
|
|
|
41573
41734
|
return json({ error: e instanceof Error ? e.message : "Failed to list profiles" }, 500, port);
|
|
41574
41735
|
}
|
|
41575
41736
|
}
|
|
41576
|
-
const profileSwitchMatch =
|
|
41737
|
+
const profileSwitchMatch = path3.match(/^\/api\/connectors\/([^/]+)\/profiles\/switch$/);
|
|
41577
41738
|
if (profileSwitchMatch && method === "POST") {
|
|
41578
41739
|
const name = profileSwitchMatch[1];
|
|
41579
41740
|
if (!isValidConnectorName(name))
|
|
@@ -41592,7 +41753,7 @@ ${result.stderr}`;
|
|
|
41592
41753
|
return json({ error: e instanceof Error ? e.message : "Failed to switch profile" }, 500, port);
|
|
41593
41754
|
}
|
|
41594
41755
|
}
|
|
41595
|
-
const profileDeleteMatch =
|
|
41756
|
+
const profileDeleteMatch = path3.match(/^\/api\/connectors\/([^/]+)\/profiles\/([^/]+)$/);
|
|
41596
41757
|
if (profileDeleteMatch && method === "DELETE") {
|
|
41597
41758
|
const name = profileDeleteMatch[1];
|
|
41598
41759
|
const profile = profileDeleteMatch[2];
|
|
@@ -41610,29 +41771,29 @@ ${result.stderr}`;
|
|
|
41610
41771
|
return json({ error: e instanceof Error ? e.message : "Failed to delete profile" }, 500, port);
|
|
41611
41772
|
}
|
|
41612
41773
|
}
|
|
41613
|
-
if (
|
|
41774
|
+
if (path3 === "/api/export" && method === "GET") {
|
|
41614
41775
|
try {
|
|
41615
41776
|
const connectDir = getConnectorsHome();
|
|
41616
41777
|
const result = {};
|
|
41617
|
-
if (
|
|
41778
|
+
if (existsSync16(connectDir)) {
|
|
41618
41779
|
for (const connectorName of listConfiguredConnectorNames(connectDir)) {
|
|
41619
41780
|
const profiles = {};
|
|
41620
41781
|
for (const configDir of [...getConnectorConfigReadDirs(connectorName, connectDir)].reverse()) {
|
|
41621
|
-
const profilesDir =
|
|
41622
|
-
if (!
|
|
41782
|
+
const profilesDir = join17(configDir, "profiles");
|
|
41783
|
+
if (!existsSync16(profilesDir))
|
|
41623
41784
|
continue;
|
|
41624
41785
|
const profileEntries = readdirSync10(profilesDir, { withFileTypes: true });
|
|
41625
41786
|
for (const pEntry of profileEntries) {
|
|
41626
41787
|
if (pEntry.isFile() && pEntry.name.endsWith(".json")) {
|
|
41627
41788
|
const profileName = basename3(pEntry.name, ".json");
|
|
41628
41789
|
try {
|
|
41629
|
-
const config2 = JSON.parse(readFileSync9(
|
|
41790
|
+
const config2 = JSON.parse(readFileSync9(join17(profilesDir, pEntry.name), "utf-8"));
|
|
41630
41791
|
profiles[profileName] = config2;
|
|
41631
41792
|
} catch {}
|
|
41632
41793
|
}
|
|
41633
41794
|
if (pEntry.isDirectory()) {
|
|
41634
|
-
const configPath =
|
|
41635
|
-
if (
|
|
41795
|
+
const configPath = join17(profilesDir, pEntry.name, "config.json");
|
|
41796
|
+
if (existsSync16(configPath)) {
|
|
41636
41797
|
try {
|
|
41637
41798
|
const config2 = JSON.parse(readFileSync9(configPath, "utf-8"));
|
|
41638
41799
|
profiles[pEntry.name] = config2;
|
|
@@ -41660,7 +41821,7 @@ ${result.stderr}`;
|
|
|
41660
41821
|
return json({ error: e instanceof Error ? e.message : "Failed to export credentials" }, 500, port);
|
|
41661
41822
|
}
|
|
41662
41823
|
}
|
|
41663
|
-
if (
|
|
41824
|
+
if (path3 === "/api/import" && method === "POST") {
|
|
41664
41825
|
try {
|
|
41665
41826
|
const contentLength = parseInt(req.headers.get("content-length") || "0", 10);
|
|
41666
41827
|
if (contentLength > MAX_BODY_SIZE)
|
|
@@ -41677,12 +41838,12 @@ ${result.stderr}`;
|
|
|
41677
41838
|
if (!data.profiles || typeof data.profiles !== "object")
|
|
41678
41839
|
continue;
|
|
41679
41840
|
const connectorDir = getConnectorConfigDir(connectorName, connectDir);
|
|
41680
|
-
const profilesDir =
|
|
41841
|
+
const profilesDir = join17(connectorDir, "profiles");
|
|
41681
41842
|
for (const [profileName, config2] of Object.entries(data.profiles)) {
|
|
41682
41843
|
if (!config2 || typeof config2 !== "object")
|
|
41683
41844
|
continue;
|
|
41684
41845
|
mkdirSync9(profilesDir, { recursive: true });
|
|
41685
|
-
const profileFile =
|
|
41846
|
+
const profileFile = join17(profilesDir, `${profileName}.json`);
|
|
41686
41847
|
writeFileSync7(profileFile, JSON.stringify(config2, null, 2));
|
|
41687
41848
|
imported++;
|
|
41688
41849
|
}
|
|
@@ -41693,7 +41854,7 @@ ${result.stderr}`;
|
|
|
41693
41854
|
return json({ error: e instanceof Error ? e.message : "Failed to import credentials" }, 500, port);
|
|
41694
41855
|
}
|
|
41695
41856
|
}
|
|
41696
|
-
const oauthStartMatch =
|
|
41857
|
+
const oauthStartMatch = path3.match(/^\/oauth\/([^/]+)\/start$/);
|
|
41697
41858
|
if (oauthStartMatch && method === "GET") {
|
|
41698
41859
|
const name = oauthStartMatch[1];
|
|
41699
41860
|
const redirectUri = `http://localhost:${port}/oauth/${name}/callback`;
|
|
@@ -41703,7 +41864,7 @@ ${result.stderr}`;
|
|
|
41703
41864
|
}
|
|
41704
41865
|
return Response.redirect(authUrl, 302);
|
|
41705
41866
|
}
|
|
41706
|
-
const oauthCallbackMatch =
|
|
41867
|
+
const oauthCallbackMatch = path3.match(/^\/oauth\/([^/]+)\/callback$/);
|
|
41707
41868
|
if (oauthCallbackMatch && method === "GET") {
|
|
41708
41869
|
const name = oauthCallbackMatch[1];
|
|
41709
41870
|
const code = url2.searchParams.get("code");
|
|
@@ -41737,16 +41898,16 @@ ${result.stderr}`;
|
|
|
41737
41898
|
});
|
|
41738
41899
|
}
|
|
41739
41900
|
if (dashboardExists && (method === "GET" || method === "HEAD")) {
|
|
41740
|
-
if (
|
|
41741
|
-
const filePath =
|
|
41742
|
-
const rel = relative2(dashboardDir,
|
|
41901
|
+
if (path3 !== "/") {
|
|
41902
|
+
const filePath = join17(dashboardDir, path3);
|
|
41903
|
+
const rel = relative2(dashboardDir, resolve2(filePath));
|
|
41743
41904
|
if (!rel.startsWith("..") && !rel.includes(`..${sep}`) && rel !== "") {
|
|
41744
41905
|
const res2 = serveStaticFile(filePath);
|
|
41745
41906
|
if (res2)
|
|
41746
41907
|
return res2;
|
|
41747
41908
|
}
|
|
41748
41909
|
}
|
|
41749
|
-
const indexPath =
|
|
41910
|
+
const indexPath = join17(dashboardDir, "index.html");
|
|
41750
41911
|
const res = serveStaticFile(indexPath);
|
|
41751
41912
|
if (res)
|
|
41752
41913
|
return res;
|
|
@@ -43314,7 +43475,7 @@ init_installer();
|
|
|
43314
43475
|
import { render } from "ink";
|
|
43315
43476
|
import chalk2 from "chalk";
|
|
43316
43477
|
import { readdirSync as readdirSync7, statSync as statSync5 } from "fs";
|
|
43317
|
-
import { join as
|
|
43478
|
+
import { join as join12, relative } from "path";
|
|
43318
43479
|
import { createInterface } from "readline";
|
|
43319
43480
|
import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
|
|
43320
43481
|
var isTTY = process.stdout.isTTY ?? false;
|
|
@@ -43329,7 +43490,7 @@ var PRESETS = {
|
|
|
43329
43490
|
function listFilesRecursive(dir, base = dir) {
|
|
43330
43491
|
const files = [];
|
|
43331
43492
|
for (const entry of readdirSync7(dir)) {
|
|
43332
|
-
const fullPath =
|
|
43493
|
+
const fullPath = join12(dir, entry);
|
|
43333
43494
|
if (statSync5(fullPath).isDirectory()) {
|
|
43334
43495
|
files.push(...listFilesRecursive(fullPath, base));
|
|
43335
43496
|
} else {
|
|
@@ -43379,9 +43540,9 @@ function registerCommands(program2) {
|
|
|
43379
43540
|
}
|
|
43380
43541
|
if (options.dryRun) {
|
|
43381
43542
|
const installed = getInstalledConnectors();
|
|
43382
|
-
const connectorsDir =
|
|
43383
|
-
const manifestPath =
|
|
43384
|
-
const indexPath =
|
|
43543
|
+
const connectorsDir = join12(process.cwd(), ".connectors");
|
|
43544
|
+
const manifestPath = join12(connectorsDir, "manifest.json");
|
|
43545
|
+
const indexPath = join12(connectorsDir, "index.ts");
|
|
43385
43546
|
const actions = [];
|
|
43386
43547
|
for (const name of connectors18) {
|
|
43387
43548
|
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
@@ -43535,14 +43696,14 @@ Installed connectors (${installed.length}):
|
|
|
43535
43696
|
console.log(` ${chalk2.cyan(name)}`);
|
|
43536
43697
|
}
|
|
43537
43698
|
console.log();
|
|
43538
|
-
const confirmed = await new Promise((
|
|
43699
|
+
const confirmed = await new Promise((resolve2) => {
|
|
43539
43700
|
const rl = createInterface({
|
|
43540
43701
|
input: process.stdin,
|
|
43541
43702
|
output: process.stdout
|
|
43542
43703
|
});
|
|
43543
43704
|
rl.question(` Update all ${installed.length} connector(s)? (y/N) `, (answer) => {
|
|
43544
43705
|
rl.close();
|
|
43545
|
-
|
|
43706
|
+
resolve2(answer.trim().toLowerCase() === "y" || answer.trim().toLowerCase() === "yes");
|
|
43546
43707
|
});
|
|
43547
43708
|
});
|
|
43548
43709
|
if (!confirmed) {
|
|
@@ -44091,8 +44252,8 @@ init_auth();
|
|
|
44091
44252
|
init_database();
|
|
44092
44253
|
init_connector_resolver();
|
|
44093
44254
|
import chalk4 from "chalk";
|
|
44094
|
-
import { existsSync as
|
|
44095
|
-
import { join as
|
|
44255
|
+
import { existsSync as existsSync17, readFileSync as readFileSync10 } from "fs";
|
|
44256
|
+
import { join as join18 } from "path";
|
|
44096
44257
|
function registerCommands3(program2) {
|
|
44097
44258
|
program2.command("status").option("--json", "Output as JSON", false).option("--limit <n>", "Limit rows per section in human output").option("--offset <n>", "Skip first N rows per section in human output").option("-v, --verbose", "Show all human rows", false).description("Show auth status of all configured connectors (project + global)").action((options) => {
|
|
44098
44259
|
const parsedLimit = parseNonNegativeInt(options.limit, "--limit");
|
|
@@ -44114,8 +44275,8 @@ function registerCommands3(program2) {
|
|
|
44114
44275
|
const auth = getAuthStatus(name);
|
|
44115
44276
|
let profile = "default";
|
|
44116
44277
|
for (const connectorConfigDir of getConnectorConfigReadDirs(name, configDir)) {
|
|
44117
|
-
const currentProfileFile =
|
|
44118
|
-
if (
|
|
44278
|
+
const currentProfileFile = join18(connectorConfigDir, "current_profile");
|
|
44279
|
+
if (existsSync17(currentProfileFile)) {
|
|
44119
44280
|
try {
|
|
44120
44281
|
profile = readFileSync10(currentProfileFile, "utf-8").trim() || "default";
|
|
44121
44282
|
} catch {}
|
|
@@ -44155,7 +44316,7 @@ function registerCommands3(program2) {
|
|
|
44155
44316
|
seen.add(name);
|
|
44156
44317
|
allStatuses.push(buildStatusEntry(name, "project"));
|
|
44157
44318
|
}
|
|
44158
|
-
if (
|
|
44319
|
+
if (existsSync17(configDir)) {
|
|
44159
44320
|
try {
|
|
44160
44321
|
for (const name of listConfiguredConnectorNames(configDir)) {
|
|
44161
44322
|
if (name.startsWith("zzztest"))
|
|
@@ -44402,9 +44563,9 @@ init_registry2();
|
|
|
44402
44563
|
init_auth();
|
|
44403
44564
|
init_database();
|
|
44404
44565
|
import chalk5 from "chalk";
|
|
44405
|
-
import { existsSync as
|
|
44406
|
-
import { join as
|
|
44407
|
-
import { homedir as
|
|
44566
|
+
import { existsSync as existsSync18, readdirSync as readdirSync11, statSync as statSync8, readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync10 } from "fs";
|
|
44567
|
+
import { join as join19 } from "path";
|
|
44568
|
+
import { homedir as homedir3 } from "os";
|
|
44408
44569
|
import { createInterface as createInterface2 } from "readline";
|
|
44409
44570
|
init_connector_resolver();
|
|
44410
44571
|
var SENSITIVE_FIELDS = new Set([
|
|
@@ -44477,10 +44638,10 @@ function getOAuthTokenState(name) {
|
|
|
44477
44638
|
})();
|
|
44478
44639
|
return { hasTokens: true, expired: isExpired, expiresIn };
|
|
44479
44640
|
}
|
|
44480
|
-
function getCurrentOAuthProfile(name,
|
|
44481
|
-
for (const dir of getConnectorConfigReadDirs(name,
|
|
44482
|
-
const currentProfilePath =
|
|
44483
|
-
if (!
|
|
44641
|
+
function getCurrentOAuthProfile(name, connectorsHome2 = getConnectorsHome()) {
|
|
44642
|
+
for (const dir of getConnectorConfigReadDirs(name, connectorsHome2)) {
|
|
44643
|
+
const currentProfilePath = join19(dir, "current_profile");
|
|
44644
|
+
if (!existsSync18(currentProfilePath))
|
|
44484
44645
|
continue;
|
|
44485
44646
|
const profile = readFileSync11(currentProfilePath, "utf8").trim();
|
|
44486
44647
|
if (profile)
|
|
@@ -44488,12 +44649,12 @@ function getCurrentOAuthProfile(name, connectorsHome = getConnectorsHome()) {
|
|
|
44488
44649
|
}
|
|
44489
44650
|
return "default";
|
|
44490
44651
|
}
|
|
44491
|
-
function getOAuthTokenPathsForProfile(name,
|
|
44492
|
-
return getConnectorConfigReadDirs(name,
|
|
44652
|
+
function getOAuthTokenPathsForProfile(name, connectorsHome2 = getConnectorsHome(), profile = getCurrentOAuthProfile(name, connectorsHome2)) {
|
|
44653
|
+
return getConnectorConfigReadDirs(name, connectorsHome2).map((dir) => join19(dir, "profiles", profile, "tokens.json"));
|
|
44493
44654
|
}
|
|
44494
44655
|
function hasOAuthTokenFileUpdatedSince(tokenPaths, sinceMs) {
|
|
44495
44656
|
return tokenPaths.some((tokensPath) => {
|
|
44496
|
-
if (!
|
|
44657
|
+
if (!existsSync18(tokensPath))
|
|
44497
44658
|
return false;
|
|
44498
44659
|
return statSync8(tokensPath).mtimeMs >= sinceMs;
|
|
44499
44660
|
});
|
|
@@ -44629,7 +44790,7 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
44629
44790
|
});
|
|
44630
44791
|
const startedAt = Date.now();
|
|
44631
44792
|
serverProc.unref();
|
|
44632
|
-
await new Promise((
|
|
44793
|
+
await new Promise((resolve3) => setTimeout(resolve3, 2000));
|
|
44633
44794
|
try {
|
|
44634
44795
|
await fetch(`http://localhost:${port}/api/connectors`);
|
|
44635
44796
|
} catch {
|
|
@@ -44643,13 +44804,13 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
44643
44804
|
console.log(` ${chalk5.cyan(oauthUrl)}
|
|
44644
44805
|
`);
|
|
44645
44806
|
console.log(chalk5.dim("Waiting for authentication to complete..."));
|
|
44646
|
-
const
|
|
44647
|
-
const activeProfile = getCurrentOAuthProfile(connector,
|
|
44648
|
-
const tokenPaths = getOAuthTokenPathsForProfile(connector,
|
|
44807
|
+
const connectorsHome2 = getConnectorsHome();
|
|
44808
|
+
const activeProfile = getCurrentOAuthProfile(connector, connectorsHome2);
|
|
44809
|
+
const tokenPaths = getOAuthTokenPathsForProfile(connector, connectorsHome2, activeProfile);
|
|
44649
44810
|
let attempts = 0;
|
|
44650
44811
|
const maxAttempts = 360;
|
|
44651
44812
|
while (attempts < maxAttempts) {
|
|
44652
|
-
await new Promise((
|
|
44813
|
+
await new Promise((resolve3) => setTimeout(resolve3, 500));
|
|
44653
44814
|
if (hasOAuthTokenFileUpdatedSince(tokenPaths, startedAt)) {
|
|
44654
44815
|
break;
|
|
44655
44816
|
}
|
|
@@ -44731,7 +44892,7 @@ Open this URL to authenticate:
|
|
|
44731
44892
|
input: process.stdin,
|
|
44732
44893
|
output: process.stdout
|
|
44733
44894
|
});
|
|
44734
|
-
const key = await new Promise((
|
|
44895
|
+
const key = await new Promise((resolve3) => {
|
|
44735
44896
|
let input = "";
|
|
44736
44897
|
process.stdout.write(` Enter ${fieldLabel}: `);
|
|
44737
44898
|
if (process.stdin.isTTY) {
|
|
@@ -44751,7 +44912,7 @@ Open this URL to authenticate:
|
|
|
44751
44912
|
}
|
|
44752
44913
|
process.stdin.pause();
|
|
44753
44914
|
rl.close();
|
|
44754
|
-
|
|
44915
|
+
resolve3(input);
|
|
44755
44916
|
} else if (c === "\x03") {
|
|
44756
44917
|
process.stdout.write(`
|
|
44757
44918
|
`);
|
|
@@ -44792,13 +44953,13 @@ Open this URL to authenticate:
|
|
|
44792
44953
|
{ key: "commerce", emoji: "\uD83D\uDCB3", label: "Commerce", connectors: ["stripe", "shopify", "paypal", "revolut", "mercury"], description: "Commerce and finance" },
|
|
44793
44954
|
{ key: "google", emoji: "\uD83D\uDCC1", label: "Google Workspace", connectors: ["gmail", "googledrive", "googlecalendar", "googledocs", "googlesheets"], description: "Google Workspace suite" }
|
|
44794
44955
|
];
|
|
44795
|
-
const
|
|
44956
|
+
const connectorsHome2 = getConnectorsHome();
|
|
44796
44957
|
let configuredCount = 0;
|
|
44797
44958
|
const configuredNames = [];
|
|
44798
44959
|
try {
|
|
44799
|
-
if (
|
|
44800
|
-
for (const name of listConfiguredConnectorNames(
|
|
44801
|
-
const hasProfiles = getConnectorConfigReadDirs(name,
|
|
44960
|
+
if (existsSync18(connectorsHome2)) {
|
|
44961
|
+
for (const name of listConfiguredConnectorNames(connectorsHome2)) {
|
|
44962
|
+
const hasProfiles = getConnectorConfigReadDirs(name, connectorsHome2).some((dir) => existsSync18(join19(dir, "profiles")));
|
|
44802
44963
|
if (hasProfiles) {
|
|
44803
44964
|
configuredCount++;
|
|
44804
44965
|
configuredNames.push(name);
|
|
@@ -44850,13 +45011,13 @@ Open this URL to authenticate:
|
|
|
44850
45011
|
program2.command("export").option("-o, --output <file>", "Write to file instead of stdout").option("--include-secrets", "Include secrets in plaintext (dangerous \u2014 use only for backup/restore)").description("Export all connector credentials as JSON backup").action((options) => {
|
|
44851
45012
|
const connectDir = getConnectorsHome();
|
|
44852
45013
|
const result = {};
|
|
44853
|
-
if (
|
|
45014
|
+
if (existsSync18(connectDir)) {
|
|
44854
45015
|
for (const connectorName of listConfiguredConnectorNames(connectDir)) {
|
|
44855
45016
|
const connectorDirs = [...getConnectorConfigReadDirs(connectorName, connectDir)].reverse();
|
|
44856
45017
|
let credentials = undefined;
|
|
44857
45018
|
for (const connectorDir of connectorDirs) {
|
|
44858
|
-
const credentialsPath =
|
|
44859
|
-
if (
|
|
45019
|
+
const credentialsPath = join19(connectorDir, "credentials.json");
|
|
45020
|
+
if (existsSync18(credentialsPath)) {
|
|
44860
45021
|
try {
|
|
44861
45022
|
credentials = JSON.parse(readFileSync11(credentialsPath, "utf-8"));
|
|
44862
45023
|
} catch {}
|
|
@@ -44864,24 +45025,24 @@ Open this URL to authenticate:
|
|
|
44864
45025
|
}
|
|
44865
45026
|
const profiles = {};
|
|
44866
45027
|
for (const connectorDir of connectorDirs) {
|
|
44867
|
-
const profilesDir =
|
|
44868
|
-
if (
|
|
45028
|
+
const profilesDir = join19(connectorDir, "profiles");
|
|
45029
|
+
if (existsSync18(profilesDir)) {
|
|
44869
45030
|
for (const pEntry of readdirSync11(profilesDir)) {
|
|
44870
|
-
const pPath =
|
|
45031
|
+
const pPath = join19(profilesDir, pEntry);
|
|
44871
45032
|
if (statSync8(pPath).isFile() && pEntry.endsWith(".json")) {
|
|
44872
45033
|
try {
|
|
44873
45034
|
profiles[pEntry.replace(/\.json$/, "")] = JSON.parse(readFileSync11(pPath, "utf-8"));
|
|
44874
45035
|
} catch {}
|
|
44875
45036
|
} else if (statSync8(pPath).isDirectory()) {
|
|
44876
|
-
const configPath =
|
|
44877
|
-
const tokensPath =
|
|
45037
|
+
const configPath = join19(pPath, "config.json");
|
|
45038
|
+
const tokensPath = join19(pPath, "tokens.json");
|
|
44878
45039
|
let merged = {};
|
|
44879
|
-
if (
|
|
45040
|
+
if (existsSync18(configPath)) {
|
|
44880
45041
|
try {
|
|
44881
45042
|
merged = { ...merged, ...JSON.parse(readFileSync11(configPath, "utf-8")) };
|
|
44882
45043
|
} catch {}
|
|
44883
45044
|
}
|
|
44884
|
-
if (
|
|
45045
|
+
if (existsSync18(tokensPath)) {
|
|
44885
45046
|
try {
|
|
44886
45047
|
merged = { ...merged, ...JSON.parse(readFileSync11(tokensPath, "utf-8")) };
|
|
44887
45048
|
} catch {}
|
|
@@ -44919,7 +45080,7 @@ Open this URL to authenticate:
|
|
|
44919
45080
|
chunks.push(chunk.toString());
|
|
44920
45081
|
raw = chunks.join("");
|
|
44921
45082
|
} else {
|
|
44922
|
-
if (!
|
|
45083
|
+
if (!existsSync18(file)) {
|
|
44923
45084
|
if (options.json) {
|
|
44924
45085
|
console.log(JSON.stringify({ error: `File not found: ${file}` }));
|
|
44925
45086
|
} else {
|
|
@@ -44959,17 +45120,17 @@ Open this URL to authenticate:
|
|
|
44959
45120
|
const connectorDir = getConnectorConfigDir(connectorName, connectDir);
|
|
44960
45121
|
if (connData.credentials && typeof connData.credentials === "object") {
|
|
44961
45122
|
mkdirSync10(connectorDir, { recursive: true });
|
|
44962
|
-
writeFileSync8(
|
|
45123
|
+
writeFileSync8(join19(connectorDir, "credentials.json"), JSON.stringify(connData.credentials, null, 2));
|
|
44963
45124
|
imported++;
|
|
44964
45125
|
}
|
|
44965
45126
|
if (!connData.profiles || typeof connData.profiles !== "object")
|
|
44966
45127
|
continue;
|
|
44967
|
-
const profilesDir =
|
|
45128
|
+
const profilesDir = join19(connectorDir, "profiles");
|
|
44968
45129
|
for (const [profileName, config2] of Object.entries(connData.profiles)) {
|
|
44969
45130
|
if (!config2 || typeof config2 !== "object")
|
|
44970
45131
|
continue;
|
|
44971
45132
|
mkdirSync10(profilesDir, { recursive: true });
|
|
44972
|
-
writeFileSync8(
|
|
45133
|
+
writeFileSync8(join19(profilesDir, `${profileName}.json`), JSON.stringify(config2, null, 2));
|
|
44973
45134
|
imported++;
|
|
44974
45135
|
}
|
|
44975
45136
|
}
|
|
@@ -44980,9 +45141,9 @@ Open this URL to authenticate:
|
|
|
44980
45141
|
}
|
|
44981
45142
|
});
|
|
44982
45143
|
program2.command("auth-import").option("--json", "Output as JSON", false).option("-d, --dry-run", "Preview what would be imported without copying", false).option("--force", "Overwrite existing files in ~/.hasna/connectors/", false).description("Migrate auth tokens from ~/.connect/ to ~/.hasna/connectors/").action((options) => {
|
|
44983
|
-
const oldBase =
|
|
45144
|
+
const oldBase = join19(homedir3(), ".connect");
|
|
44984
45145
|
const newBase = getConnectorsHome();
|
|
44985
|
-
if (!
|
|
45146
|
+
if (!existsSync18(oldBase)) {
|
|
44986
45147
|
if (options.json) {
|
|
44987
45148
|
console.log(JSON.stringify({ imported: [], skipped: [], error: null, message: "No ~/.connect/ directory found" }));
|
|
44988
45149
|
} else {
|
|
@@ -44994,7 +45155,7 @@ Open this URL to authenticate:
|
|
|
44994
45155
|
if (!name.startsWith("connect-"))
|
|
44995
45156
|
return false;
|
|
44996
45157
|
try {
|
|
44997
|
-
return statSync8(
|
|
45158
|
+
return statSync8(join19(oldBase, name)).isDirectory();
|
|
44998
45159
|
} catch {
|
|
44999
45160
|
return false;
|
|
45000
45161
|
}
|
|
@@ -45010,7 +45171,7 @@ Open this URL to authenticate:
|
|
|
45010
45171
|
const imported = [];
|
|
45011
45172
|
const skipped = [];
|
|
45012
45173
|
for (const dirName of entries) {
|
|
45013
|
-
const oldDir =
|
|
45174
|
+
const oldDir = join19(oldBase, dirName);
|
|
45014
45175
|
const connectorName = dirName.replace(/^connect-/, "");
|
|
45015
45176
|
const newDir = getConnectorConfigDir(connectorName, newBase);
|
|
45016
45177
|
const allFiles = listFilesRecursive(oldDir);
|
|
@@ -45022,14 +45183,14 @@ Open this URL to authenticate:
|
|
|
45022
45183
|
const copiedFiles = [];
|
|
45023
45184
|
const skippedFiles = [];
|
|
45024
45185
|
for (const relFile of authFiles) {
|
|
45025
|
-
const srcPath =
|
|
45026
|
-
const destPath =
|
|
45027
|
-
if (
|
|
45186
|
+
const srcPath = join19(oldDir, relFile);
|
|
45187
|
+
const destPath = join19(newDir, relFile);
|
|
45188
|
+
if (existsSync18(destPath) && !options.force) {
|
|
45028
45189
|
skippedFiles.push(relFile);
|
|
45029
45190
|
continue;
|
|
45030
45191
|
}
|
|
45031
45192
|
if (!options.dryRun) {
|
|
45032
|
-
const parentDir =
|
|
45193
|
+
const parentDir = join19(destPath, "..");
|
|
45033
45194
|
mkdirSync10(parentDir, { recursive: true });
|
|
45034
45195
|
const content = readFileSync11(srcPath);
|
|
45035
45196
|
writeFileSync8(destPath, content);
|
|
@@ -45098,8 +45259,8 @@ init_installer();
|
|
|
45098
45259
|
init_auth();
|
|
45099
45260
|
init_database();
|
|
45100
45261
|
import chalk6 from "chalk";
|
|
45101
|
-
import { existsSync as
|
|
45102
|
-
import { join as
|
|
45262
|
+
import { existsSync as existsSync19, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "fs";
|
|
45263
|
+
import { join as join20 } from "path";
|
|
45103
45264
|
|
|
45104
45265
|
// src/lib/test-endpoints.ts
|
|
45105
45266
|
var TEST_ENDPOINTS = {
|
|
@@ -45580,8 +45741,8 @@ Available presets:
|
|
|
45580
45741
|
unconfigured++;
|
|
45581
45742
|
let profile = "default";
|
|
45582
45743
|
for (const connectorConfigDir of getConnectorConfigReadDirs(name, configDir)) {
|
|
45583
|
-
const currentProfileFile =
|
|
45584
|
-
if (
|
|
45744
|
+
const currentProfileFile = join20(connectorConfigDir, "current_profile");
|
|
45745
|
+
if (existsSync19(currentProfileFile)) {
|
|
45585
45746
|
try {
|
|
45586
45747
|
profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
|
|
45587
45748
|
} catch {}
|
|
@@ -45590,7 +45751,7 @@ Available presets:
|
|
|
45590
45751
|
}
|
|
45591
45752
|
connectorDetails.push({ name, configured: auth.configured, authType: auth.type, profile, source: "project" });
|
|
45592
45753
|
}
|
|
45593
|
-
if (
|
|
45754
|
+
if (existsSync19(configDir)) {
|
|
45594
45755
|
try {
|
|
45595
45756
|
for (const name of listConfiguredConnectorNames(configDir)) {
|
|
45596
45757
|
if (seen.has(name))
|
|
@@ -45602,8 +45763,8 @@ Available presets:
|
|
|
45602
45763
|
configured++;
|
|
45603
45764
|
let profile = "default";
|
|
45604
45765
|
for (const connectorConfigDir of getConnectorConfigReadDirs(name, configDir)) {
|
|
45605
|
-
const currentProfileFile =
|
|
45606
|
-
if (
|
|
45766
|
+
const currentProfileFile = join20(connectorConfigDir, "current_profile");
|
|
45767
|
+
if (existsSync19(currentProfileFile)) {
|
|
45607
45768
|
try {
|
|
45608
45769
|
profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
|
|
45609
45770
|
} catch {}
|
|
@@ -45618,7 +45779,7 @@ Available presets:
|
|
|
45618
45779
|
console.log(JSON.stringify({
|
|
45619
45780
|
version: version2,
|
|
45620
45781
|
configDir,
|
|
45621
|
-
configDirExists:
|
|
45782
|
+
configDirExists: existsSync19(configDir),
|
|
45622
45783
|
installed: installed.length,
|
|
45623
45784
|
configured,
|
|
45624
45785
|
unconfigured,
|
|
@@ -45630,7 +45791,7 @@ Available presets:
|
|
|
45630
45791
|
Connectors Setup
|
|
45631
45792
|
`));
|
|
45632
45793
|
console.log(` Version: ${chalk6.cyan(version2)}`);
|
|
45633
|
-
console.log(` Config: ${configDir}${
|
|
45794
|
+
console.log(` Config: ${configDir}${existsSync19(configDir) ? "" : chalk6.dim(" (not created yet)")}`);
|
|
45634
45795
|
console.log(` Installed: ${installed.length} connector${installed.length !== 1 ? "s" : ""}`);
|
|
45635
45796
|
console.log(` Configured: ${chalk6.green(String(configured))} ready, ${unconfigured > 0 ? chalk6.red(String(unconfigured)) : chalk6.dim("0")} need auth`);
|
|
45636
45797
|
const projectConnectors = connectorDetails.filter((c) => c.source === "project");
|
|
@@ -45738,15 +45899,15 @@ Testing connector credentials...
|
|
|
45738
45899
|
const connectorConfigDirs = getConnectorConfigReadDirs(name);
|
|
45739
45900
|
let currentProfile = "default";
|
|
45740
45901
|
for (const connectorConfigDir of connectorConfigDirs) {
|
|
45741
|
-
const currentProfileFile =
|
|
45742
|
-
if (
|
|
45902
|
+
const currentProfileFile = join20(connectorConfigDir, "current_profile");
|
|
45903
|
+
if (existsSync19(currentProfileFile)) {
|
|
45743
45904
|
try {
|
|
45744
45905
|
currentProfile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
|
|
45745
45906
|
} catch {}
|
|
45746
45907
|
break;
|
|
45747
45908
|
}
|
|
45748
45909
|
}
|
|
45749
|
-
const tokensFile = connectorConfigDirs.map((dir) =>
|
|
45910
|
+
const tokensFile = connectorConfigDirs.map((dir) => join20(dir, "profiles", currentProfile, "tokens.json")).find((path3) => existsSync19(path3));
|
|
45750
45911
|
if (tokensFile) {
|
|
45751
45912
|
try {
|
|
45752
45913
|
const tokens = JSON.parse(readFileSync12(tokensFile, "utf-8"));
|
|
@@ -45768,8 +45929,8 @@ Testing connector credentials...
|
|
|
45768
45929
|
}
|
|
45769
45930
|
if (!apiKey) {
|
|
45770
45931
|
for (const connectorConfigDir of connectorConfigDirs) {
|
|
45771
|
-
const profileFile =
|
|
45772
|
-
if (
|
|
45932
|
+
const profileFile = join20(connectorConfigDir, "profiles", `${currentProfile}.json`);
|
|
45933
|
+
if (existsSync19(profileFile)) {
|
|
45773
45934
|
try {
|
|
45774
45935
|
const config2 = JSON.parse(readFileSync12(profileFile, "utf-8"));
|
|
45775
45936
|
apiKey = Object.values(config2).find((v) => typeof v === "string" && v.length > 0);
|
|
@@ -45781,8 +45942,8 @@ Testing connector credentials...
|
|
|
45781
45942
|
}
|
|
45782
45943
|
if (!apiKey) {
|
|
45783
45944
|
for (const connectorConfigDir of connectorConfigDirs) {
|
|
45784
|
-
const profileDirConfig =
|
|
45785
|
-
if (
|
|
45945
|
+
const profileDirConfig = join20(connectorConfigDir, "profiles", currentProfile, "config.json");
|
|
45946
|
+
if (existsSync19(profileDirConfig)) {
|
|
45786
45947
|
try {
|
|
45787
45948
|
const config2 = JSON.parse(readFileSync12(profileDirConfig, "utf-8"));
|
|
45788
45949
|
apiKey = Object.values(config2).find((v) => typeof v === "string" && v.length > 0);
|
|
@@ -46054,7 +46215,7 @@ Setting up ${meta.displayName}...
|
|
|
46054
46215
|
});
|
|
46055
46216
|
const startedAt = Date.now();
|
|
46056
46217
|
serverProc.unref();
|
|
46057
|
-
await new Promise((
|
|
46218
|
+
await new Promise((resolve3) => setTimeout(resolve3, 2000));
|
|
46058
46219
|
try {
|
|
46059
46220
|
await fetch(`http://localhost:${port}/api/connectors`);
|
|
46060
46221
|
} catch {
|
|
@@ -46063,13 +46224,13 @@ Setting up ${meta.displayName}...
|
|
|
46063
46224
|
return;
|
|
46064
46225
|
}
|
|
46065
46226
|
console.log(chalk7.dim(" Waiting for authentication to complete..."));
|
|
46066
|
-
const
|
|
46067
|
-
const activeProfile = getCurrentOAuthProfile(name,
|
|
46068
|
-
const tokenPaths = getOAuthTokenPathsForProfile(name,
|
|
46227
|
+
const connectorsHome2 = getConnectorsHome2();
|
|
46228
|
+
const activeProfile = getCurrentOAuthProfile(name, connectorsHome2);
|
|
46229
|
+
const tokenPaths = getOAuthTokenPathsForProfile(name, connectorsHome2, activeProfile);
|
|
46069
46230
|
let attempts = 0;
|
|
46070
46231
|
const maxAttempts = 360;
|
|
46071
46232
|
while (attempts < maxAttempts) {
|
|
46072
|
-
await new Promise((
|
|
46233
|
+
await new Promise((resolve3) => setTimeout(resolve3, 500));
|
|
46073
46234
|
if (hasOAuthTokenFileUpdatedSince(tokenPaths, startedAt))
|
|
46074
46235
|
break;
|
|
46075
46236
|
attempts++;
|