@hasna/connectors 1.4.4 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.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
- // src/core/connectors/gmail.ts
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 { basename, join as join2 } from "path";
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 ?? join2(configDirs()[0], "attachments", messageId);
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 = join2(outputDir, filename);
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((resolve) => setTimeout(resolve, ms));
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 baseDir of configDirs()) {
7137
- const profilesDir = join2(baseDir, "profiles");
7138
- if (!existsSync2(profilesDir))
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 baseDir of configDirs()) {
7263
+ for (const baseDir2 of configDirs()) {
7155
7264
  const credentials = {
7156
- ...readJson(join2(baseDir, "credentials.json")),
7157
- ...readJson(join2(baseDir, "profiles", profile, "config.json"))
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 baseDir of configDirs()) {
7166
- const fromProfile = readJson(join2(baseDir, "profiles", profile, "tokens.json"));
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(join2(baseDir, "profiles", `${profile}.json`));
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 baseDir = configDirs().find((dir) => existsSync2(dir)) ?? configDirs()[0];
7177
- const profileDir = join2(baseDir, "profiles", profile);
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(join2(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
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 baseDir = process.env.HASNA_CONNECTORS_DIR ?? join2(homedir(), ".hasna", "connectors");
7186
- return [join2(baseDir, "gmail"), join2(baseDir, "connect-gmail")];
7294
+ const baseDir2 = connectorsHome();
7295
+ return [join4(baseDir2, "gmail"), join4(baseDir2, "connect-gmail")];
7187
7296
  }
7188
7297
  function readJson(path) {
7189
- if (!existsSync2(path))
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 existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync2 } from "fs";
7440
- import { homedir as homedir2 } from "os";
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 baseDir of configDirs2()) {
7509
- const profilesDir = join3(baseDir, "profiles");
7510
- if (!existsSync3(profilesDir))
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 baseDir of configDirs2()) {
7664
+ for (const baseDir2 of configDirs2()) {
7556
7665
  const credentials = {
7557
- ...readJson2(join3(baseDir, "credentials.json")),
7558
- ...readJson2(join3(baseDir, "profiles", profile, "config.json"))
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 baseDir of configDirs2()) {
7567
- const fromProfile = readJson2(join3(baseDir, "profiles", profile, "tokens.json"));
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(join3(baseDir, "profiles", `${profile}.json`));
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 baseDir = configDirs2().find((dir) => existsSync3(dir)) ?? configDirs2()[0];
7578
- const profileDir = join3(baseDir, "profiles", profile);
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(join3(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
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 baseDir = process.env.HASNA_CONNECTORS_DIR ?? join3(homedir2(), ".hasna", "connectors");
7587
- return [join3(baseDir, "googledrive"), join3(baseDir, "connect-googledrive")];
7695
+ const baseDir2 = connectorsHome();
7696
+ return [join5(baseDir2, "googledrive"), join5(baseDir2, "connect-googledrive")];
7588
7697
  }
7589
7698
  function readJson2(path) {
7590
- if (!existsSync3(path))
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 join4 } from "path";
7838
- import { homedir as homedir3 } from "os";
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 (!existsSync4(sourceDir)) {
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 = join4(sourceDir, entry);
7847
- const targetPath = join4(targetDir, entry);
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 (!existsSync4(targetPath)) {
7963
+ if (!existsSync5(targetPath)) {
7855
7964
  copyFileSync(sourcePath, targetPath);
7856
7965
  }
7857
7966
  } catch {}
7858
7967
  }
7859
7968
  }
7860
7969
  function getConnectorsHome() {
7861
- const home = process.env["HOME"] || process.env["USERPROFILE"] || homedir3();
7862
- const newDir = join4(home, ".hasna", "connectors");
7863
- const legacyDirs = [join4(home, ".connectors"), join4(home, ".connect")];
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 = join4(DB_DIR, "connectors.db");
8122
+ DB_PATH = join6(DB_DIR, "connectors.db");
8013
8123
  });
8014
8124
 
8015
8125
  // src/lib/connector-resolver.ts
8016
- import { existsSync as existsSync5, readdirSync as readdirSync4, statSync as statSync2 } from "fs";
8017
- import { join as join5 } from "path";
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) => join5(connectorsDir, dirName));
8061
- const existingPath = checkedPaths.find((path) => existsSync5(path)) ?? null;
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, connectorsHome = getConnectorsHome()) {
8187
+ function resolveConnectorConfigPaths(name, connectorsHome2 = getConnectorsHome()) {
8078
8188
  const resolution = resolveConnectorName(name);
8079
8189
  const preferredDirName = resolution.canonicalName || resolution.legacyName;
8080
- const preferredPath = join5(connectorsHome, preferredDirName);
8081
- const legacyPath = join5(connectorsHome, resolution.legacyName);
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) => existsSync5(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, connectorsHome = getConnectorsHome()) {
8095
- return resolveConnectorConfigPaths(name, connectorsHome).preferredPath;
8204
+ function getConnectorConfigDir(name, connectorsHome2 = getConnectorsHome()) {
8205
+ return resolveConnectorConfigPaths(name, connectorsHome2).preferredPath;
8096
8206
  }
8097
- function getConnectorConfigReadDirs(name, connectorsHome = getConnectorsHome()) {
8098
- return resolveConnectorConfigPaths(name, connectorsHome).readPaths;
8207
+ function getConnectorConfigReadDirs(name, connectorsHome2 = getConnectorsHome()) {
8208
+ return resolveConnectorConfigPaths(name, connectorsHome2).readPaths;
8099
8209
  }
8100
- function listConfiguredConnectorNames(connectorsHome = getConnectorsHome()) {
8101
- if (!existsSync5(connectorsHome))
8210
+ function listConfiguredConnectorNames(connectorsHome2 = getConnectorsHome()) {
8211
+ if (!existsSync6(connectorsHome2))
8102
8212
  return [];
8103
8213
  const names = new Set;
8104
- for (const entry of readdirSync4(connectorsHome)) {
8105
- const fullPath = join5(connectorsHome, entry);
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 existsSync6,
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 join6 } from "path";
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 join6(getConfigDir(), "profiles");
8297
+ return join8(getConfigDir(), "profiles");
8188
8298
  }
8189
8299
  function getCurrentProfile() {
8190
8300
  for (const configDir of getConfigReadDirs()) {
8191
- const currentProfileFile = join6(configDir, "current_profile");
8192
- if (!existsSync6(currentProfileFile))
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(join6(configDir, "current_profile"), profile);
8315
+ writeFileSync3(join8(configDir, "current_profile"), profile);
8206
8316
  }
8207
8317
  function getFlatProfilePath(profile) {
8208
- return join6(getProfilesDir(), `${profile}.json`);
8318
+ return join8(getProfilesDir(), `${profile}.json`);
8209
8319
  }
8210
8320
  function getFlatProfileReadPaths(profile) {
8211
- return getConfigReadDirs().map((dir) => join6(dir, "profiles", `${profile}.json`));
8321
+ return getConfigReadDirs().map((dir) => join8(dir, "profiles", `${profile}.json`));
8212
8322
  }
8213
8323
  function getDirectoryProfileReadPaths(profile) {
8214
- return getConfigReadDirs().map((dir) => join6(dir, "profiles", profile, "config.json"));
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, ...existsSync6(path) ? loadJsonFile(path) : {} }), {});
8235
- const directoryConfig = getDirectoryProfileReadPaths(profile).reverse().reduce((config, path) => ({ ...config, ...existsSync6(path) ? loadJsonFile(path) : {} }), {});
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) => existsSync6(path)) || getConfigReadDirs().some((dir) => existsSync6(join6(dir, "profiles", profile)));
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 = join6(configDir, "profiles");
8257
- if (!existsSync6(profilesDir))
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 = join6(profilesDir, entry);
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 = join6(getProfilesDir(), profile);
8284
- if (existsSync6(flatPath)) {
8393
+ const directoryPath = join8(getProfilesDir(), profile);
8394
+ if (existsSync7(flatPath)) {
8285
8395
  rmSync(flatPath);
8286
8396
  }
8287
- if (existsSync6(directoryPath)) {
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 existsSync7 } from "fs";
9214
- import { dirname as dirname3, join as join7 } from "path";
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
- join7(__dirname3, "..", "..", "..", "connectors", "stripe"),
9219
- join7(__dirname3, "..", "..", "connectors", "stripe"),
9220
- join7(__dirname3, "..", "connectors", "stripe"),
9221
- join7(process.cwd(), "connectors", "stripe")
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 (existsSync7(candidate)) {
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(join7(CONNECTOR_DIR2, "src", "api", "index.ts")).href);
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(join7(CONNECTOR_DIR2, "src", "utils", "config.ts")).href);
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 existsSync8, readFileSync as readFileSync4 } from "fs";
18400
- import { join as join8, dirname as dirname4 } from "path";
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
- join8(thisDir, "..", "connectors"),
18565
- join8(thisDir, "..", "..", "connectors")
18674
+ join10(thisDir, "..", "connectors"),
18675
+ join10(thisDir, "..", "..", "connectors")
18566
18676
  ];
18567
- const connectorsDir = candidates.find((d) => existsSync8(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 = join8(getConnectorPackagePath(connectorsDir, connector.name), "package.json");
18573
- if (existsSync8(pkgPath)) {
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 existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync4, readdirSync as readdirSync6, statSync as statSync4, rmSync as rmSync2 } from "fs";
20299
- import { join as join9, dirname as dirname5 } from "path";
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 = join9(__dirname4, "..", "connectors");
20303
- if (existsSync9(fromBin))
20412
+ const fromBin = join11(__dirname4, "..", "connectors");
20413
+ if (existsSync10(fromBin))
20304
20414
  return fromBin;
20305
- const fromSrc = join9(__dirname4, "..", "..", "connectors");
20306
- if (existsSync9(fromSrc))
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 join9(targetDir, PROJECT_CONNECTORS_DIRNAME);
20421
+ return join11(targetDir, PROJECT_CONNECTORS_DIRNAME);
20312
20422
  }
20313
20423
  function getEnablementManifestPath(targetDir) {
20314
- return join9(getProjectConnectorsDir(targetDir), ENABLEMENT_MANIFEST_FILENAME);
20424
+ return join11(getProjectConnectorsDir(targetDir), ENABLEMENT_MANIFEST_FILENAME);
20315
20425
  }
20316
20426
  function getLegacyInstallPath(targetDir, name) {
20317
- return join9(getProjectConnectorsDir(targetDir), legacyConnectorName(name));
20427
+ return join11(getProjectConnectorsDir(targetDir), legacyConnectorName(name));
20318
20428
  }
20319
20429
  function loadEnablementManifest(targetDir) {
20320
20430
  const manifestPath = getEnablementManifestPath(targetDir);
20321
- if (!existsSync9(manifestPath)) {
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 (!existsSync9(connectorsDir)) {
20451
+ if (!existsSync10(connectorsDir)) {
20342
20452
  return [];
20343
20453
  }
20344
20454
  return readdirSync6(connectorsDir).filter((entry) => {
20345
- const fullPath = join9(connectorsDir, entry);
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 = join9(connectorsDir, ENABLEMENT_INDEX_FILENAME);
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) || existsSync9(getConnectorPath(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 && existsSync9(legacyInstallPath)) {
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 = join9(connectorPath, "CLAUDE.md");
20459
- if (existsSync9(claudeMdPath)) {
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 (existsSync9(legacyInstallPath)) {
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 existsSync10, statSync as statSync6 } from "fs";
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 (existsSync10(path) && isStale(path)) {
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((resolve) => setTimeout(resolve, LOCK_RETRY_MS));
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 existsSync11, readFileSync as readFileSync6, writeFileSync as writeFileSync5, mkdirSync as mkdirSync7, readdirSync as readdirSync8, rmSync as rmSync3, statSync as statSync7 } from "fs";
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 join11 } from "path";
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 = join11(configDir, "current_profile");
20701
- if (existsSync11(currentProfileFile)) {
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 = join11(configDir, "profiles", `${profile}.json`);
20715
- if (existsSync11(profileFile)) {
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 = join11(configDir, "profiles", profile, "config.json");
20721
- if (existsSync11(profileDirConfig)) {
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 = join11(configDir, "profiles", profile, "tokens.json");
20742
- if (existsSync11(tokensFile)) {
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 = join11(configDir, "credentials.json");
20985
+ const credentialsFile = join13(configDir, "credentials.json");
20876
20986
  ensurePrivateDir(configDir);
20877
20987
  let creds = {};
20878
- if (existsSync11(credentialsFile)) {
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 = join11(configDir, "profiles");
20888
- const profileFile = join11(profilesDir, `${profile}.json`);
20889
- const profileDir = join11(profilesDir, profile);
20890
- if (existsSync11(profileFile)) {
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 (existsSync11(profileDir)) {
20902
- const configFile = join11(profileDir, "config.json");
21011
+ if (existsSync12(profileDir)) {
21012
+ const configFile = join13(profileDir, "config.json");
20903
21013
  let config = {};
20904
- if (existsSync11(configFile)) {
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(join11(profileDir, "config.json"), { [keyField]: key });
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 = join11(configDir, "credentials.json");
20942
- if (existsSync11(credentialsFile)) {
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 = join11(configDir, "profiles");
21029
- const profileDir = join11(profilesDir, profile);
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 = join11(profileDir, "tokens.json");
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 = join11(configDir, "profiles");
21081
- if (!existsSync11(profilesDir))
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 = join11(profilesDir, entry);
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(join11(configDir, "current_profile"), profile);
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 = join11(configDir, "profiles");
21111
- const profileFile = join11(profilesDir, `${profile}.json`);
21112
- if (existsSync11(profileFile)) {
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 = join11(profilesDir, profile);
21120
- if (existsSync11(profileDir)) {
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 existsSync12, readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync8 } from "fs";
21409
- import { join as join12 } from "path";
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 join12(getConnectorsHome(), "llm.json");
21521
+ return join14(getConnectorsHome(), "llm.json");
21412
21522
  }
21413
21523
  function getLlmConfig() {
21414
21524
  const path = getLlmConfigPath();
21415
- if (!existsSync12(path))
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((resolve) => {
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) => resolve({ exitCode: code ?? 1, output }));
21747
- proc.on("error", () => resolve({ exitCode: 1, output: `Failed to spawn connectors run` }));
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
- resolve({ exitCode: 124, output: output + `
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((resolve) => {
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) => resolve({ exitCode: code ?? 1, output }));
21833
- proc.on("error", () => resolve({ exitCode: 1, output: "Failed to spawn connectors" }));
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
- resolve({ exitCode: 124, output: output + `
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 existsSync13, readdirSync as readdirSync9 } from "fs";
21885
- import { join as join13, dirname as dirname6 } from "path";
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 = join13(__dirname5, "..", "connectors");
21890
- if (existsSync13(fromBin))
21999
+ const fromBin = join15(__dirname5, "..", "connectors");
22000
+ if (existsSync14(fromBin))
21891
22001
  return fromBin;
21892
- const fromSrc = join13(__dirname5, "..", "..", "connectors");
21893
- if (existsSync13(fromSrc))
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 = join13(connectorDir, "src", "cli", "index.ts");
21962
- if (existsSync13(cliPath))
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((resolve) => {
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
- resolve({
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
- resolve({
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((resolve) => {
28428
+ return new Promise((resolve2) => {
28319
28429
  this._streamMapping.set(streamId, {
28320
- resolveJson: resolve,
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((resolve) => setTimeout(resolve, pollInterval));
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((resolve, reject) => {
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
- resolve(parseResult.data);
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((resolve, reject) => {
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(resolve, interval);
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 = resolve.call(this, root, ref);
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 resolve(root, ref) {
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 resolve(baseURI, relativeURI, options) {
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((resolve) => setTimeout(resolve, pollInterval));
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 existsSync14, readFileSync as readFileSync8 } from "fs";
39371
- import { join as join14 } from "path";
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 connectorsHome = getConnectorsHome();
39507
- const tokenPaths = getConnectorConfigReadDirs(name, connectorsHome).map((dir) => join14(dir, "profiles", "default", "tokens.json"));
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((resolve) => setTimeout(resolve, 2000));
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((resolve) => setTimeout(resolve, 500));
39526
- if (tokenPaths.some((tokensPath) => existsSync14(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) => existsSync14(path)) ?? tokenPaths[0];
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: [{
@@ -40915,19 +41025,19 @@ var fallbackAttemptSymbol, __dirname6, localXdgOpenPath, platform, arch, tryEach
40915
41025
  }
40916
41026
  const subprocess = childProcess4.spawn(command, cliArguments, childProcessOptions);
40917
41027
  if (options.wait) {
40918
- return new Promise((resolve, reject) => {
41028
+ return new Promise((resolve2, reject) => {
40919
41029
  subprocess.once("error", reject);
40920
41030
  subprocess.once("close", (exitCode) => {
40921
41031
  if (!options.allowNonzeroExitCode && exitCode !== 0) {
40922
41032
  reject(new Error(`Exited with code ${exitCode}`));
40923
41033
  return;
40924
41034
  }
40925
- resolve(subprocess);
41035
+ resolve2(subprocess);
40926
41036
  });
40927
41037
  });
40928
41038
  }
40929
41039
  if (isFallbackAttempt) {
40930
- return new Promise((resolve, reject) => {
41040
+ return new Promise((resolve2, reject) => {
40931
41041
  subprocess.once("error", reject);
40932
41042
  subprocess.once("spawn", () => {
40933
41043
  subprocess.once("close", (exitCode) => {
@@ -40937,17 +41047,17 @@ var fallbackAttemptSymbol, __dirname6, localXdgOpenPath, platform, arch, tryEach
40937
41047
  return;
40938
41048
  }
40939
41049
  subprocess.unref();
40940
- resolve(subprocess);
41050
+ resolve2(subprocess);
40941
41051
  });
40942
41052
  });
40943
41053
  });
40944
41054
  }
40945
41055
  subprocess.unref();
40946
- return new Promise((resolve, reject) => {
41056
+ return new Promise((resolve2, reject) => {
40947
41057
  subprocess.once("error", reject);
40948
41058
  subprocess.once("spawn", () => {
40949
41059
  subprocess.off("error", reject);
40950
- resolve(subprocess);
41060
+ resolve2(subprocess);
40951
41061
  });
40952
41062
  });
40953
41063
  }, open = (target, options) => {
@@ -41035,8 +41145,8 @@ var exports_serve = {};
41035
41145
  __export(exports_serve, {
41036
41146
  startServer: () => startServer
41037
41147
  });
41038
- import { existsSync as existsSync15, readdirSync as readdirSync10, readFileSync as readFileSync9, writeFileSync as writeFileSync7, mkdirSync as mkdirSync9 } from "fs";
41039
- import { join as join15, dirname as dirname7, extname, basename as basename3, relative as relative2, resolve, sep } from "path";
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";
41040
41150
  import { fileURLToPath as fileURLToPath7 } from "url";
41041
41151
  function logActivity(action, connector, detail) {
41042
41152
  activityLog.unshift({ action, connector, timestamp: Date.now(), detail });
@@ -41048,20 +41158,20 @@ function resolveDashboardDir() {
41048
41158
  const candidates = [];
41049
41159
  try {
41050
41160
  const scriptDir = dirname7(fileURLToPath7(import.meta.url));
41051
- candidates.push(join15(scriptDir, "..", "dashboard", "dist"));
41052
- candidates.push(join15(scriptDir, "..", "..", "dashboard", "dist"));
41161
+ candidates.push(join17(scriptDir, "..", "dashboard", "dist"));
41162
+ candidates.push(join17(scriptDir, "..", "..", "dashboard", "dist"));
41053
41163
  } catch {}
41054
41164
  if (process.argv[1]) {
41055
41165
  const mainDir = dirname7(process.argv[1]);
41056
- candidates.push(join15(mainDir, "..", "dashboard", "dist"));
41057
- candidates.push(join15(mainDir, "..", "..", "dashboard", "dist"));
41166
+ candidates.push(join17(mainDir, "..", "dashboard", "dist"));
41167
+ candidates.push(join17(mainDir, "..", "..", "dashboard", "dist"));
41058
41168
  }
41059
- candidates.push(join15(process.cwd(), "dashboard", "dist"));
41169
+ candidates.push(join17(process.cwd(), "dashboard", "dist"));
41060
41170
  for (const candidate of candidates) {
41061
- if (existsSync15(candidate))
41171
+ if (existsSync16(candidate))
41062
41172
  return candidate;
41063
41173
  }
41064
- return join15(process.cwd(), "dashboard", "dist");
41174
+ return join17(process.cwd(), "dashboard", "dist");
41065
41175
  }
41066
41176
  function json(data, status = 200, port) {
41067
41177
  return new Response(JSON.stringify(data), {
@@ -41143,7 +41253,7 @@ function oauthPage(type, title, message, hint, extra) {
41143
41253
  </body></html>`;
41144
41254
  }
41145
41255
  function serveStaticFile(filePath) {
41146
- if (!existsSync15(filePath))
41256
+ if (!existsSync16(filePath))
41147
41257
  return null;
41148
41258
  const ext = extname(filePath);
41149
41259
  const contentType2 = MIME_TYPES[ext] || "application/octet-stream";
@@ -41180,7 +41290,7 @@ async function startServer(requestedPort, options) {
41180
41290
  const strict = options?.strict ?? false;
41181
41291
  loadConnectorVersions();
41182
41292
  const dashboardDir = resolveDashboardDir();
41183
- const dashboardExists = existsSync15(dashboardDir);
41293
+ const dashboardExists = existsSync16(dashboardDir);
41184
41294
  if (!dashboardExists) {
41185
41295
  console.error(`
41186
41296
  Dashboard not found at: ${dashboardDir}`);
@@ -41611,8 +41721,8 @@ ${result.stderr}`;
41611
41721
  const profiles = listProfiles4(name);
41612
41722
  let current = "default";
41613
41723
  for (const configDir of getConnectorConfigReadDirs(name)) {
41614
- const currentProfileFile = join15(configDir, "current_profile");
41615
- if (existsSync15(currentProfileFile)) {
41724
+ const currentProfileFile = join17(configDir, "current_profile");
41725
+ if (existsSync16(currentProfileFile)) {
41616
41726
  try {
41617
41727
  current = readFileSync9(currentProfileFile, "utf-8").trim() || "default";
41618
41728
  } catch {}
@@ -41665,25 +41775,25 @@ ${result.stderr}`;
41665
41775
  try {
41666
41776
  const connectDir = getConnectorsHome();
41667
41777
  const result = {};
41668
- if (existsSync15(connectDir)) {
41778
+ if (existsSync16(connectDir)) {
41669
41779
  for (const connectorName of listConfiguredConnectorNames(connectDir)) {
41670
41780
  const profiles = {};
41671
41781
  for (const configDir of [...getConnectorConfigReadDirs(connectorName, connectDir)].reverse()) {
41672
- const profilesDir = join15(configDir, "profiles");
41673
- if (!existsSync15(profilesDir))
41782
+ const profilesDir = join17(configDir, "profiles");
41783
+ if (!existsSync16(profilesDir))
41674
41784
  continue;
41675
41785
  const profileEntries = readdirSync10(profilesDir, { withFileTypes: true });
41676
41786
  for (const pEntry of profileEntries) {
41677
41787
  if (pEntry.isFile() && pEntry.name.endsWith(".json")) {
41678
41788
  const profileName = basename3(pEntry.name, ".json");
41679
41789
  try {
41680
- const config2 = JSON.parse(readFileSync9(join15(profilesDir, pEntry.name), "utf-8"));
41790
+ const config2 = JSON.parse(readFileSync9(join17(profilesDir, pEntry.name), "utf-8"));
41681
41791
  profiles[profileName] = config2;
41682
41792
  } catch {}
41683
41793
  }
41684
41794
  if (pEntry.isDirectory()) {
41685
- const configPath = join15(profilesDir, pEntry.name, "config.json");
41686
- if (existsSync15(configPath)) {
41795
+ const configPath = join17(profilesDir, pEntry.name, "config.json");
41796
+ if (existsSync16(configPath)) {
41687
41797
  try {
41688
41798
  const config2 = JSON.parse(readFileSync9(configPath, "utf-8"));
41689
41799
  profiles[pEntry.name] = config2;
@@ -41728,12 +41838,12 @@ ${result.stderr}`;
41728
41838
  if (!data.profiles || typeof data.profiles !== "object")
41729
41839
  continue;
41730
41840
  const connectorDir = getConnectorConfigDir(connectorName, connectDir);
41731
- const profilesDir = join15(connectorDir, "profiles");
41841
+ const profilesDir = join17(connectorDir, "profiles");
41732
41842
  for (const [profileName, config2] of Object.entries(data.profiles)) {
41733
41843
  if (!config2 || typeof config2 !== "object")
41734
41844
  continue;
41735
41845
  mkdirSync9(profilesDir, { recursive: true });
41736
- const profileFile = join15(profilesDir, `${profileName}.json`);
41846
+ const profileFile = join17(profilesDir, `${profileName}.json`);
41737
41847
  writeFileSync7(profileFile, JSON.stringify(config2, null, 2));
41738
41848
  imported++;
41739
41849
  }
@@ -41789,15 +41899,15 @@ ${result.stderr}`;
41789
41899
  }
41790
41900
  if (dashboardExists && (method === "GET" || method === "HEAD")) {
41791
41901
  if (path3 !== "/") {
41792
- const filePath = join15(dashboardDir, path3);
41793
- const rel = relative2(dashboardDir, resolve(filePath));
41902
+ const filePath = join17(dashboardDir, path3);
41903
+ const rel = relative2(dashboardDir, resolve2(filePath));
41794
41904
  if (!rel.startsWith("..") && !rel.includes(`..${sep}`) && rel !== "") {
41795
41905
  const res2 = serveStaticFile(filePath);
41796
41906
  if (res2)
41797
41907
  return res2;
41798
41908
  }
41799
41909
  }
41800
- const indexPath = join15(dashboardDir, "index.html");
41910
+ const indexPath = join17(dashboardDir, "index.html");
41801
41911
  const res = serveStaticFile(indexPath);
41802
41912
  if (res)
41803
41913
  return res;
@@ -43365,7 +43475,7 @@ init_installer();
43365
43475
  import { render } from "ink";
43366
43476
  import chalk2 from "chalk";
43367
43477
  import { readdirSync as readdirSync7, statSync as statSync5 } from "fs";
43368
- import { join as join10, relative } from "path";
43478
+ import { join as join12, relative } from "path";
43369
43479
  import { createInterface } from "readline";
43370
43480
  import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
43371
43481
  var isTTY = process.stdout.isTTY ?? false;
@@ -43380,7 +43490,7 @@ var PRESETS = {
43380
43490
  function listFilesRecursive(dir, base = dir) {
43381
43491
  const files = [];
43382
43492
  for (const entry of readdirSync7(dir)) {
43383
- const fullPath = join10(dir, entry);
43493
+ const fullPath = join12(dir, entry);
43384
43494
  if (statSync5(fullPath).isDirectory()) {
43385
43495
  files.push(...listFilesRecursive(fullPath, base));
43386
43496
  } else {
@@ -43430,9 +43540,9 @@ function registerCommands(program2) {
43430
43540
  }
43431
43541
  if (options.dryRun) {
43432
43542
  const installed = getInstalledConnectors();
43433
- const connectorsDir = join10(process.cwd(), ".connectors");
43434
- const manifestPath = join10(connectorsDir, "manifest.json");
43435
- const indexPath = join10(connectorsDir, "index.ts");
43543
+ const connectorsDir = join12(process.cwd(), ".connectors");
43544
+ const manifestPath = join12(connectorsDir, "manifest.json");
43545
+ const indexPath = join12(connectorsDir, "index.ts");
43436
43546
  const actions = [];
43437
43547
  for (const name of connectors18) {
43438
43548
  if (!/^[a-z0-9-]+$/.test(name)) {
@@ -43586,14 +43696,14 @@ Installed connectors (${installed.length}):
43586
43696
  console.log(` ${chalk2.cyan(name)}`);
43587
43697
  }
43588
43698
  console.log();
43589
- const confirmed = await new Promise((resolve) => {
43699
+ const confirmed = await new Promise((resolve2) => {
43590
43700
  const rl = createInterface({
43591
43701
  input: process.stdin,
43592
43702
  output: process.stdout
43593
43703
  });
43594
43704
  rl.question(` Update all ${installed.length} connector(s)? (y/N) `, (answer) => {
43595
43705
  rl.close();
43596
- resolve(answer.trim().toLowerCase() === "y" || answer.trim().toLowerCase() === "yes");
43706
+ resolve2(answer.trim().toLowerCase() === "y" || answer.trim().toLowerCase() === "yes");
43597
43707
  });
43598
43708
  });
43599
43709
  if (!confirmed) {
@@ -44142,8 +44252,8 @@ init_auth();
44142
44252
  init_database();
44143
44253
  init_connector_resolver();
44144
44254
  import chalk4 from "chalk";
44145
- import { existsSync as existsSync16, readFileSync as readFileSync10 } from "fs";
44146
- import { join as join16 } from "path";
44255
+ import { existsSync as existsSync17, readFileSync as readFileSync10 } from "fs";
44256
+ import { join as join18 } from "path";
44147
44257
  function registerCommands3(program2) {
44148
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) => {
44149
44259
  const parsedLimit = parseNonNegativeInt(options.limit, "--limit");
@@ -44165,8 +44275,8 @@ function registerCommands3(program2) {
44165
44275
  const auth = getAuthStatus(name);
44166
44276
  let profile = "default";
44167
44277
  for (const connectorConfigDir of getConnectorConfigReadDirs(name, configDir)) {
44168
- const currentProfileFile = join16(connectorConfigDir, "current_profile");
44169
- if (existsSync16(currentProfileFile)) {
44278
+ const currentProfileFile = join18(connectorConfigDir, "current_profile");
44279
+ if (existsSync17(currentProfileFile)) {
44170
44280
  try {
44171
44281
  profile = readFileSync10(currentProfileFile, "utf-8").trim() || "default";
44172
44282
  } catch {}
@@ -44206,7 +44316,7 @@ function registerCommands3(program2) {
44206
44316
  seen.add(name);
44207
44317
  allStatuses.push(buildStatusEntry(name, "project"));
44208
44318
  }
44209
- if (existsSync16(configDir)) {
44319
+ if (existsSync17(configDir)) {
44210
44320
  try {
44211
44321
  for (const name of listConfiguredConnectorNames(configDir)) {
44212
44322
  if (name.startsWith("zzztest"))
@@ -44453,9 +44563,9 @@ init_registry2();
44453
44563
  init_auth();
44454
44564
  init_database();
44455
44565
  import chalk5 from "chalk";
44456
- import { existsSync as existsSync17, readdirSync as readdirSync11, statSync as statSync8, readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync10 } from "fs";
44457
- import { join as join17 } from "path";
44458
- import { homedir as homedir4 } from "os";
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";
44459
44569
  import { createInterface as createInterface2 } from "readline";
44460
44570
  init_connector_resolver();
44461
44571
  var SENSITIVE_FIELDS = new Set([
@@ -44528,10 +44638,10 @@ function getOAuthTokenState(name) {
44528
44638
  })();
44529
44639
  return { hasTokens: true, expired: isExpired, expiresIn };
44530
44640
  }
44531
- function getCurrentOAuthProfile(name, connectorsHome = getConnectorsHome()) {
44532
- for (const dir of getConnectorConfigReadDirs(name, connectorsHome)) {
44533
- const currentProfilePath = join17(dir, "current_profile");
44534
- if (!existsSync17(currentProfilePath))
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))
44535
44645
  continue;
44536
44646
  const profile = readFileSync11(currentProfilePath, "utf8").trim();
44537
44647
  if (profile)
@@ -44539,12 +44649,12 @@ function getCurrentOAuthProfile(name, connectorsHome = getConnectorsHome()) {
44539
44649
  }
44540
44650
  return "default";
44541
44651
  }
44542
- function getOAuthTokenPathsForProfile(name, connectorsHome = getConnectorsHome(), profile = getCurrentOAuthProfile(name, connectorsHome)) {
44543
- return getConnectorConfigReadDirs(name, connectorsHome).map((dir) => join17(dir, "profiles", profile, "tokens.json"));
44652
+ function getOAuthTokenPathsForProfile(name, connectorsHome2 = getConnectorsHome(), profile = getCurrentOAuthProfile(name, connectorsHome2)) {
44653
+ return getConnectorConfigReadDirs(name, connectorsHome2).map((dir) => join19(dir, "profiles", profile, "tokens.json"));
44544
44654
  }
44545
44655
  function hasOAuthTokenFileUpdatedSince(tokenPaths, sinceMs) {
44546
44656
  return tokenPaths.some((tokensPath) => {
44547
- if (!existsSync17(tokensPath))
44657
+ if (!existsSync18(tokensPath))
44548
44658
  return false;
44549
44659
  return statSync8(tokensPath).mtimeMs >= sinceMs;
44550
44660
  });
@@ -44680,7 +44790,7 @@ ${meta.displayName} \u2014 Auth Configuration
44680
44790
  });
44681
44791
  const startedAt = Date.now();
44682
44792
  serverProc.unref();
44683
- await new Promise((resolve2) => setTimeout(resolve2, 2000));
44793
+ await new Promise((resolve3) => setTimeout(resolve3, 2000));
44684
44794
  try {
44685
44795
  await fetch(`http://localhost:${port}/api/connectors`);
44686
44796
  } catch {
@@ -44694,13 +44804,13 @@ ${meta.displayName} \u2014 Auth Configuration
44694
44804
  console.log(` ${chalk5.cyan(oauthUrl)}
44695
44805
  `);
44696
44806
  console.log(chalk5.dim("Waiting for authentication to complete..."));
44697
- const connectorsHome = getConnectorsHome();
44698
- const activeProfile = getCurrentOAuthProfile(connector, connectorsHome);
44699
- const tokenPaths = getOAuthTokenPathsForProfile(connector, connectorsHome, activeProfile);
44807
+ const connectorsHome2 = getConnectorsHome();
44808
+ const activeProfile = getCurrentOAuthProfile(connector, connectorsHome2);
44809
+ const tokenPaths = getOAuthTokenPathsForProfile(connector, connectorsHome2, activeProfile);
44700
44810
  let attempts = 0;
44701
44811
  const maxAttempts = 360;
44702
44812
  while (attempts < maxAttempts) {
44703
- await new Promise((resolve2) => setTimeout(resolve2, 500));
44813
+ await new Promise((resolve3) => setTimeout(resolve3, 500));
44704
44814
  if (hasOAuthTokenFileUpdatedSince(tokenPaths, startedAt)) {
44705
44815
  break;
44706
44816
  }
@@ -44782,7 +44892,7 @@ Open this URL to authenticate:
44782
44892
  input: process.stdin,
44783
44893
  output: process.stdout
44784
44894
  });
44785
- const key = await new Promise((resolve2) => {
44895
+ const key = await new Promise((resolve3) => {
44786
44896
  let input = "";
44787
44897
  process.stdout.write(` Enter ${fieldLabel}: `);
44788
44898
  if (process.stdin.isTTY) {
@@ -44802,7 +44912,7 @@ Open this URL to authenticate:
44802
44912
  }
44803
44913
  process.stdin.pause();
44804
44914
  rl.close();
44805
- resolve2(input);
44915
+ resolve3(input);
44806
44916
  } else if (c === "\x03") {
44807
44917
  process.stdout.write(`
44808
44918
  `);
@@ -44843,13 +44953,13 @@ Open this URL to authenticate:
44843
44953
  { key: "commerce", emoji: "\uD83D\uDCB3", label: "Commerce", connectors: ["stripe", "shopify", "paypal", "revolut", "mercury"], description: "Commerce and finance" },
44844
44954
  { key: "google", emoji: "\uD83D\uDCC1", label: "Google Workspace", connectors: ["gmail", "googledrive", "googlecalendar", "googledocs", "googlesheets"], description: "Google Workspace suite" }
44845
44955
  ];
44846
- const connectorsHome = getConnectorsHome();
44956
+ const connectorsHome2 = getConnectorsHome();
44847
44957
  let configuredCount = 0;
44848
44958
  const configuredNames = [];
44849
44959
  try {
44850
- if (existsSync17(connectorsHome)) {
44851
- for (const name of listConfiguredConnectorNames(connectorsHome)) {
44852
- const hasProfiles = getConnectorConfigReadDirs(name, connectorsHome).some((dir) => existsSync17(join17(dir, "profiles")));
44960
+ if (existsSync18(connectorsHome2)) {
44961
+ for (const name of listConfiguredConnectorNames(connectorsHome2)) {
44962
+ const hasProfiles = getConnectorConfigReadDirs(name, connectorsHome2).some((dir) => existsSync18(join19(dir, "profiles")));
44853
44963
  if (hasProfiles) {
44854
44964
  configuredCount++;
44855
44965
  configuredNames.push(name);
@@ -44901,13 +45011,13 @@ Open this URL to authenticate:
44901
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) => {
44902
45012
  const connectDir = getConnectorsHome();
44903
45013
  const result = {};
44904
- if (existsSync17(connectDir)) {
45014
+ if (existsSync18(connectDir)) {
44905
45015
  for (const connectorName of listConfiguredConnectorNames(connectDir)) {
44906
45016
  const connectorDirs = [...getConnectorConfigReadDirs(connectorName, connectDir)].reverse();
44907
45017
  let credentials = undefined;
44908
45018
  for (const connectorDir of connectorDirs) {
44909
- const credentialsPath = join17(connectorDir, "credentials.json");
44910
- if (existsSync17(credentialsPath)) {
45019
+ const credentialsPath = join19(connectorDir, "credentials.json");
45020
+ if (existsSync18(credentialsPath)) {
44911
45021
  try {
44912
45022
  credentials = JSON.parse(readFileSync11(credentialsPath, "utf-8"));
44913
45023
  } catch {}
@@ -44915,24 +45025,24 @@ Open this URL to authenticate:
44915
45025
  }
44916
45026
  const profiles = {};
44917
45027
  for (const connectorDir of connectorDirs) {
44918
- const profilesDir = join17(connectorDir, "profiles");
44919
- if (existsSync17(profilesDir)) {
45028
+ const profilesDir = join19(connectorDir, "profiles");
45029
+ if (existsSync18(profilesDir)) {
44920
45030
  for (const pEntry of readdirSync11(profilesDir)) {
44921
- const pPath = join17(profilesDir, pEntry);
45031
+ const pPath = join19(profilesDir, pEntry);
44922
45032
  if (statSync8(pPath).isFile() && pEntry.endsWith(".json")) {
44923
45033
  try {
44924
45034
  profiles[pEntry.replace(/\.json$/, "")] = JSON.parse(readFileSync11(pPath, "utf-8"));
44925
45035
  } catch {}
44926
45036
  } else if (statSync8(pPath).isDirectory()) {
44927
- const configPath = join17(pPath, "config.json");
44928
- const tokensPath = join17(pPath, "tokens.json");
45037
+ const configPath = join19(pPath, "config.json");
45038
+ const tokensPath = join19(pPath, "tokens.json");
44929
45039
  let merged = {};
44930
- if (existsSync17(configPath)) {
45040
+ if (existsSync18(configPath)) {
44931
45041
  try {
44932
45042
  merged = { ...merged, ...JSON.parse(readFileSync11(configPath, "utf-8")) };
44933
45043
  } catch {}
44934
45044
  }
44935
- if (existsSync17(tokensPath)) {
45045
+ if (existsSync18(tokensPath)) {
44936
45046
  try {
44937
45047
  merged = { ...merged, ...JSON.parse(readFileSync11(tokensPath, "utf-8")) };
44938
45048
  } catch {}
@@ -44970,7 +45080,7 @@ Open this URL to authenticate:
44970
45080
  chunks.push(chunk.toString());
44971
45081
  raw = chunks.join("");
44972
45082
  } else {
44973
- if (!existsSync17(file)) {
45083
+ if (!existsSync18(file)) {
44974
45084
  if (options.json) {
44975
45085
  console.log(JSON.stringify({ error: `File not found: ${file}` }));
44976
45086
  } else {
@@ -45010,17 +45120,17 @@ Open this URL to authenticate:
45010
45120
  const connectorDir = getConnectorConfigDir(connectorName, connectDir);
45011
45121
  if (connData.credentials && typeof connData.credentials === "object") {
45012
45122
  mkdirSync10(connectorDir, { recursive: true });
45013
- writeFileSync8(join17(connectorDir, "credentials.json"), JSON.stringify(connData.credentials, null, 2));
45123
+ writeFileSync8(join19(connectorDir, "credentials.json"), JSON.stringify(connData.credentials, null, 2));
45014
45124
  imported++;
45015
45125
  }
45016
45126
  if (!connData.profiles || typeof connData.profiles !== "object")
45017
45127
  continue;
45018
- const profilesDir = join17(connectorDir, "profiles");
45128
+ const profilesDir = join19(connectorDir, "profiles");
45019
45129
  for (const [profileName, config2] of Object.entries(connData.profiles)) {
45020
45130
  if (!config2 || typeof config2 !== "object")
45021
45131
  continue;
45022
45132
  mkdirSync10(profilesDir, { recursive: true });
45023
- writeFileSync8(join17(profilesDir, `${profileName}.json`), JSON.stringify(config2, null, 2));
45133
+ writeFileSync8(join19(profilesDir, `${profileName}.json`), JSON.stringify(config2, null, 2));
45024
45134
  imported++;
45025
45135
  }
45026
45136
  }
@@ -45031,9 +45141,9 @@ Open this URL to authenticate:
45031
45141
  }
45032
45142
  });
45033
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) => {
45034
- const oldBase = join17(homedir4(), ".connect");
45144
+ const oldBase = join19(homedir3(), ".connect");
45035
45145
  const newBase = getConnectorsHome();
45036
- if (!existsSync17(oldBase)) {
45146
+ if (!existsSync18(oldBase)) {
45037
45147
  if (options.json) {
45038
45148
  console.log(JSON.stringify({ imported: [], skipped: [], error: null, message: "No ~/.connect/ directory found" }));
45039
45149
  } else {
@@ -45045,7 +45155,7 @@ Open this URL to authenticate:
45045
45155
  if (!name.startsWith("connect-"))
45046
45156
  return false;
45047
45157
  try {
45048
- return statSync8(join17(oldBase, name)).isDirectory();
45158
+ return statSync8(join19(oldBase, name)).isDirectory();
45049
45159
  } catch {
45050
45160
  return false;
45051
45161
  }
@@ -45061,7 +45171,7 @@ Open this URL to authenticate:
45061
45171
  const imported = [];
45062
45172
  const skipped = [];
45063
45173
  for (const dirName of entries) {
45064
- const oldDir = join17(oldBase, dirName);
45174
+ const oldDir = join19(oldBase, dirName);
45065
45175
  const connectorName = dirName.replace(/^connect-/, "");
45066
45176
  const newDir = getConnectorConfigDir(connectorName, newBase);
45067
45177
  const allFiles = listFilesRecursive(oldDir);
@@ -45073,14 +45183,14 @@ Open this URL to authenticate:
45073
45183
  const copiedFiles = [];
45074
45184
  const skippedFiles = [];
45075
45185
  for (const relFile of authFiles) {
45076
- const srcPath = join17(oldDir, relFile);
45077
- const destPath = join17(newDir, relFile);
45078
- if (existsSync17(destPath) && !options.force) {
45186
+ const srcPath = join19(oldDir, relFile);
45187
+ const destPath = join19(newDir, relFile);
45188
+ if (existsSync18(destPath) && !options.force) {
45079
45189
  skippedFiles.push(relFile);
45080
45190
  continue;
45081
45191
  }
45082
45192
  if (!options.dryRun) {
45083
- const parentDir = join17(destPath, "..");
45193
+ const parentDir = join19(destPath, "..");
45084
45194
  mkdirSync10(parentDir, { recursive: true });
45085
45195
  const content = readFileSync11(srcPath);
45086
45196
  writeFileSync8(destPath, content);
@@ -45149,8 +45259,8 @@ init_installer();
45149
45259
  init_auth();
45150
45260
  init_database();
45151
45261
  import chalk6 from "chalk";
45152
- import { existsSync as existsSync18, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "fs";
45153
- import { join as join18 } from "path";
45262
+ import { existsSync as existsSync19, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "fs";
45263
+ import { join as join20 } from "path";
45154
45264
 
45155
45265
  // src/lib/test-endpoints.ts
45156
45266
  var TEST_ENDPOINTS = {
@@ -45631,8 +45741,8 @@ Available presets:
45631
45741
  unconfigured++;
45632
45742
  let profile = "default";
45633
45743
  for (const connectorConfigDir of getConnectorConfigReadDirs(name, configDir)) {
45634
- const currentProfileFile = join18(connectorConfigDir, "current_profile");
45635
- if (existsSync18(currentProfileFile)) {
45744
+ const currentProfileFile = join20(connectorConfigDir, "current_profile");
45745
+ if (existsSync19(currentProfileFile)) {
45636
45746
  try {
45637
45747
  profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
45638
45748
  } catch {}
@@ -45641,7 +45751,7 @@ Available presets:
45641
45751
  }
45642
45752
  connectorDetails.push({ name, configured: auth.configured, authType: auth.type, profile, source: "project" });
45643
45753
  }
45644
- if (existsSync18(configDir)) {
45754
+ if (existsSync19(configDir)) {
45645
45755
  try {
45646
45756
  for (const name of listConfiguredConnectorNames(configDir)) {
45647
45757
  if (seen.has(name))
@@ -45653,8 +45763,8 @@ Available presets:
45653
45763
  configured++;
45654
45764
  let profile = "default";
45655
45765
  for (const connectorConfigDir of getConnectorConfigReadDirs(name, configDir)) {
45656
- const currentProfileFile = join18(connectorConfigDir, "current_profile");
45657
- if (existsSync18(currentProfileFile)) {
45766
+ const currentProfileFile = join20(connectorConfigDir, "current_profile");
45767
+ if (existsSync19(currentProfileFile)) {
45658
45768
  try {
45659
45769
  profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
45660
45770
  } catch {}
@@ -45669,7 +45779,7 @@ Available presets:
45669
45779
  console.log(JSON.stringify({
45670
45780
  version: version2,
45671
45781
  configDir,
45672
- configDirExists: existsSync18(configDir),
45782
+ configDirExists: existsSync19(configDir),
45673
45783
  installed: installed.length,
45674
45784
  configured,
45675
45785
  unconfigured,
@@ -45681,7 +45791,7 @@ Available presets:
45681
45791
  Connectors Setup
45682
45792
  `));
45683
45793
  console.log(` Version: ${chalk6.cyan(version2)}`);
45684
- console.log(` Config: ${configDir}${existsSync18(configDir) ? "" : chalk6.dim(" (not created yet)")}`);
45794
+ console.log(` Config: ${configDir}${existsSync19(configDir) ? "" : chalk6.dim(" (not created yet)")}`);
45685
45795
  console.log(` Installed: ${installed.length} connector${installed.length !== 1 ? "s" : ""}`);
45686
45796
  console.log(` Configured: ${chalk6.green(String(configured))} ready, ${unconfigured > 0 ? chalk6.red(String(unconfigured)) : chalk6.dim("0")} need auth`);
45687
45797
  const projectConnectors = connectorDetails.filter((c) => c.source === "project");
@@ -45789,15 +45899,15 @@ Testing connector credentials...
45789
45899
  const connectorConfigDirs = getConnectorConfigReadDirs(name);
45790
45900
  let currentProfile = "default";
45791
45901
  for (const connectorConfigDir of connectorConfigDirs) {
45792
- const currentProfileFile = join18(connectorConfigDir, "current_profile");
45793
- if (existsSync18(currentProfileFile)) {
45902
+ const currentProfileFile = join20(connectorConfigDir, "current_profile");
45903
+ if (existsSync19(currentProfileFile)) {
45794
45904
  try {
45795
45905
  currentProfile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
45796
45906
  } catch {}
45797
45907
  break;
45798
45908
  }
45799
45909
  }
45800
- const tokensFile = connectorConfigDirs.map((dir) => join18(dir, "profiles", currentProfile, "tokens.json")).find((path3) => existsSync18(path3));
45910
+ const tokensFile = connectorConfigDirs.map((dir) => join20(dir, "profiles", currentProfile, "tokens.json")).find((path3) => existsSync19(path3));
45801
45911
  if (tokensFile) {
45802
45912
  try {
45803
45913
  const tokens = JSON.parse(readFileSync12(tokensFile, "utf-8"));
@@ -45819,8 +45929,8 @@ Testing connector credentials...
45819
45929
  }
45820
45930
  if (!apiKey) {
45821
45931
  for (const connectorConfigDir of connectorConfigDirs) {
45822
- const profileFile = join18(connectorConfigDir, "profiles", `${currentProfile}.json`);
45823
- if (existsSync18(profileFile)) {
45932
+ const profileFile = join20(connectorConfigDir, "profiles", `${currentProfile}.json`);
45933
+ if (existsSync19(profileFile)) {
45824
45934
  try {
45825
45935
  const config2 = JSON.parse(readFileSync12(profileFile, "utf-8"));
45826
45936
  apiKey = Object.values(config2).find((v) => typeof v === "string" && v.length > 0);
@@ -45832,8 +45942,8 @@ Testing connector credentials...
45832
45942
  }
45833
45943
  if (!apiKey) {
45834
45944
  for (const connectorConfigDir of connectorConfigDirs) {
45835
- const profileDirConfig = join18(connectorConfigDir, "profiles", currentProfile, "config.json");
45836
- if (existsSync18(profileDirConfig)) {
45945
+ const profileDirConfig = join20(connectorConfigDir, "profiles", currentProfile, "config.json");
45946
+ if (existsSync19(profileDirConfig)) {
45837
45947
  try {
45838
45948
  const config2 = JSON.parse(readFileSync12(profileDirConfig, "utf-8"));
45839
45949
  apiKey = Object.values(config2).find((v) => typeof v === "string" && v.length > 0);
@@ -46105,7 +46215,7 @@ Setting up ${meta.displayName}...
46105
46215
  });
46106
46216
  const startedAt = Date.now();
46107
46217
  serverProc.unref();
46108
- await new Promise((resolve2) => setTimeout(resolve2, 2000));
46218
+ await new Promise((resolve3) => setTimeout(resolve3, 2000));
46109
46219
  try {
46110
46220
  await fetch(`http://localhost:${port}/api/connectors`);
46111
46221
  } catch {
@@ -46114,13 +46224,13 @@ Setting up ${meta.displayName}...
46114
46224
  return;
46115
46225
  }
46116
46226
  console.log(chalk7.dim(" Waiting for authentication to complete..."));
46117
- const connectorsHome = getConnectorsHome2();
46118
- const activeProfile = getCurrentOAuthProfile(name, connectorsHome);
46119
- const tokenPaths = getOAuthTokenPathsForProfile(name, connectorsHome, activeProfile);
46227
+ const connectorsHome2 = getConnectorsHome2();
46228
+ const activeProfile = getCurrentOAuthProfile(name, connectorsHome2);
46229
+ const tokenPaths = getOAuthTokenPathsForProfile(name, connectorsHome2, activeProfile);
46120
46230
  let attempts = 0;
46121
46231
  const maxAttempts = 360;
46122
46232
  while (attempts < maxAttempts) {
46123
- await new Promise((resolve2) => setTimeout(resolve2, 500));
46233
+ await new Promise((resolve3) => setTimeout(resolve3, 500));
46124
46234
  if (hasOAuthTokenFileUpdatedSince(tokenPaths, startedAt))
46125
46235
  break;
46126
46236
  attempts++;