@hasna/connectors 1.3.23 → 1.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/bin/index.js +492 -153
  2. package/bin/mcp.js +1078 -595
  3. package/bin/serve.js +774 -436
  4. package/connectors/connect-cloudflare/bun.lock +32 -0
  5. package/connectors/connect-gmail/bin/index.js +7027 -0
  6. package/connectors/connect-googledrive/bin/index.js +5958 -0
  7. package/connectors/connect-imessage/bin/.gitkeep +2 -0
  8. package/connectors/connect-imessage/bin/index.js +3016 -0
  9. package/connectors/connect-imessage/bun.lock +32 -0
  10. package/connectors/connect-imessage/package.json +46 -0
  11. package/connectors/connect-imessage/src/api/client.ts +139 -0
  12. package/connectors/connect-imessage/src/api/conversations.ts +49 -0
  13. package/connectors/connect-imessage/src/api/health.ts +16 -0
  14. package/connectors/connect-imessage/src/api/index.ts +62 -0
  15. package/connectors/connect-imessage/src/api/messages.ts +119 -0
  16. package/connectors/connect-imessage/src/cli/index.ts +258 -0
  17. package/connectors/connect-imessage/src/index.ts +26 -0
  18. package/connectors/connect-imessage/src/types/index.ts +134 -0
  19. package/connectors/connect-imessage/src/utils/config.ts +219 -0
  20. package/connectors/connect-imessage/src/utils/output.ts +121 -0
  21. package/connectors/connect-imessage/tsconfig.json +16 -0
  22. package/dist/core/builtins.test.d.ts +1 -0
  23. package/dist/core/connectors/googledrive.d.ts +6 -0
  24. package/dist/core/connectors/internal-operations.test.d.ts +1 -0
  25. package/dist/core/connectors/internal-runtime.test.d.ts +1 -0
  26. package/dist/core/errors.test.d.ts +1 -0
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +640 -86
  29. package/dist/lib/runner-auth.test.d.ts +1 -0
  30. package/dist/lib/runner.d.ts +31 -0
  31. package/dist/lib/test-endpoints.test.d.ts +1 -0
  32. package/dist/lib/workflow-runner.d.ts +7 -0
  33. package/dist/server/auth-exchange.test.d.ts +1 -0
  34. package/dist/server/auth-refresh.test.d.ts +1 -0
  35. package/dist/server/auth.d.ts +1 -0
  36. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -65,7 +65,7 @@ var __export = (target, all) => {
65
65
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
66
66
  var __require = import.meta.require;
67
67
 
68
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/error.js
68
+ // node_modules/commander/lib/error.js
69
69
  var require_error = __commonJS((exports) => {
70
70
  class CommanderError extends Error {
71
71
  constructor(exitCode, code, message) {
@@ -89,7 +89,7 @@ var require_error = __commonJS((exports) => {
89
89
  exports.InvalidArgumentError = InvalidArgumentError;
90
90
  });
91
91
 
92
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/argument.js
92
+ // node_modules/commander/lib/argument.js
93
93
  var require_argument = __commonJS((exports) => {
94
94
  var { InvalidArgumentError } = require_error();
95
95
 
@@ -168,7 +168,7 @@ var require_argument = __commonJS((exports) => {
168
168
  exports.humanReadableArgName = humanReadableArgName;
169
169
  });
170
170
 
171
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/help.js
171
+ // node_modules/commander/lib/help.js
172
172
  var require_help = __commonJS((exports) => {
173
173
  var { humanReadableArgName } = require_argument();
174
174
 
@@ -417,7 +417,7 @@ var require_help = __commonJS((exports) => {
417
417
  exports.Help = Help;
418
418
  });
419
419
 
420
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/option.js
420
+ // node_modules/commander/lib/option.js
421
421
  var require_option = __commonJS((exports) => {
422
422
  var { InvalidArgumentError } = require_error();
423
423
 
@@ -568,7 +568,7 @@ var require_option = __commonJS((exports) => {
568
568
  exports.DualOptions = DualOptions;
569
569
  });
570
570
 
571
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/suggestSimilar.js
571
+ // node_modules/commander/lib/suggestSimilar.js
572
572
  var require_suggestSimilar = __commonJS((exports) => {
573
573
  var maxDistance = 3;
574
574
  function editDistance(a, b) {
@@ -641,7 +641,7 @@ var require_suggestSimilar = __commonJS((exports) => {
641
641
  exports.suggestSimilar = suggestSimilar;
642
642
  });
643
643
 
644
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/command.js
644
+ // node_modules/commander/lib/command.js
645
645
  var require_command = __commonJS((exports) => {
646
646
  var EventEmitter = __require("events").EventEmitter;
647
647
  var childProcess = __require("child_process");
@@ -1884,7 +1884,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1884
1884
  exports.Command = Command;
1885
1885
  });
1886
1886
 
1887
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/index.js
1887
+ // node_modules/commander/index.js
1888
1888
  var require_commander = __commonJS((exports) => {
1889
1889
  var { Argument } = require_argument();
1890
1890
  var { Command } = require_command();
@@ -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.3.23",
1912
+ version: "1.3.25",
1913
1913
  description: "Open source connector library - Install API connectors with a single command",
1914
1914
  type: "module",
1915
1915
  bin: {
@@ -2052,7 +2052,7 @@ var CONNECTOR_NAME_RE, OPERATION_NAME_RE;
2052
2052
  var init_connector = __esm(() => {
2053
2053
  init_errors();
2054
2054
  CONNECTOR_NAME_RE = /^[a-z0-9-]+$/;
2055
- OPERATION_NAME_RE = /^[a-z0-9:_-]+$/;
2055
+ OPERATION_NAME_RE = /^[a-z0-9:._-]+$/;
2056
2056
  });
2057
2057
 
2058
2058
  // src/core/registry.ts
@@ -2081,7 +2081,7 @@ var init_registry = __esm(() => {
2081
2081
  init_connector();
2082
2082
  });
2083
2083
 
2084
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/helpers/util.js
2084
+ // node_modules/zod/v3/helpers/util.js
2085
2085
  var util, objectUtil, ZodParsedType, getParsedType = (data) => {
2086
2086
  const t = typeof data;
2087
2087
  switch (t) {
@@ -2212,7 +2212,7 @@ var init_util = __esm(() => {
2212
2212
  ]);
2213
2213
  });
2214
2214
 
2215
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/ZodError.js
2215
+ // node_modules/zod/v3/ZodError.js
2216
2216
  var ZodIssueCode, quotelessJson = (obj) => {
2217
2217
  const json = JSON.stringify(obj, null, 2);
2218
2218
  return json.replace(/"([^"]+)":/g, "$1:");
@@ -2333,7 +2333,7 @@ var init_ZodError = __esm(() => {
2333
2333
  };
2334
2334
  });
2335
2335
 
2336
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/locales/en.js
2336
+ // node_modules/zod/v3/locales/en.js
2337
2337
  var errorMap = (issue, _ctx) => {
2338
2338
  let message;
2339
2339
  switch (issue.code) {
@@ -2440,7 +2440,7 @@ var init_en = __esm(() => {
2440
2440
  en_default = errorMap;
2441
2441
  });
2442
2442
 
2443
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/errors.js
2443
+ // node_modules/zod/v3/errors.js
2444
2444
  function setErrorMap(map) {
2445
2445
  overrideErrorMap = map;
2446
2446
  }
@@ -2453,7 +2453,7 @@ var init_errors2 = __esm(() => {
2453
2453
  overrideErrorMap = en_default;
2454
2454
  });
2455
2455
 
2456
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/helpers/parseUtil.js
2456
+ // node_modules/zod/v3/helpers/parseUtil.js
2457
2457
  function addIssueToContext(ctx, issueData) {
2458
2458
  const overrideMap = getErrorMap();
2459
2459
  const issue = makeIssue({
@@ -2558,10 +2558,10 @@ var init_parseUtil = __esm(() => {
2558
2558
  });
2559
2559
  });
2560
2560
 
2561
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/helpers/typeAliases.js
2561
+ // node_modules/zod/v3/helpers/typeAliases.js
2562
2562
  var init_typeAliases = () => {};
2563
2563
 
2564
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/helpers/errorUtil.js
2564
+ // node_modules/zod/v3/helpers/errorUtil.js
2565
2565
  var errorUtil;
2566
2566
  var init_errorUtil = __esm(() => {
2567
2567
  (function(errorUtil2) {
@@ -2570,7 +2570,7 @@ var init_errorUtil = __esm(() => {
2570
2570
  })(errorUtil || (errorUtil = {}));
2571
2571
  });
2572
2572
 
2573
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/types.js
2573
+ // node_modules/zod/v3/types.js
2574
2574
  class ParseInputLazyPath {
2575
2575
  constructor(parent, value, path, key) {
2576
2576
  this._cachedPath = [];
@@ -5921,7 +5921,7 @@ var init_types = __esm(() => {
5921
5921
  NEVER = INVALID;
5922
5922
  });
5923
5923
 
5924
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/external.js
5924
+ // node_modules/zod/v3/external.js
5925
5925
  var exports_external = {};
5926
5926
  __export(exports_external, {
5927
5927
  void: () => voidType,
@@ -6041,7 +6041,7 @@ var init_external = __esm(() => {
6041
6041
  init_ZodError();
6042
6042
  });
6043
6043
 
6044
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/index.js
6044
+ // node_modules/zod/index.js
6045
6045
  var init_zod = __esm(() => {
6046
6046
  init_external();
6047
6047
  init_external();
@@ -6913,7 +6913,300 @@ Commands:
6913
6913
  });
6914
6914
  });
6915
6915
 
6916
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/@hasna/cloud/dist/index.js
6916
+ // src/core/connectors/googledrive.ts
6917
+ import { existsSync as existsSync2, mkdirSync, readFileSync, readdirSync, writeFileSync } from "fs";
6918
+ import { homedir } from "os";
6919
+ import { basename, join as join2 } from "path";
6920
+ async function requestJson(profile, path, params) {
6921
+ const response = await request(profile, path, params);
6922
+ const text = await response.text();
6923
+ return text ? JSON.parse(text) : {};
6924
+ }
6925
+ async function requestBinary(profile, path, params) {
6926
+ return (await request(profile, path, params)).arrayBuffer();
6927
+ }
6928
+ async function request(profile, path, params) {
6929
+ const token = await getValidAccessToken(profile);
6930
+ const url = new URL(`${DRIVE_API_BASE}${path}`);
6931
+ for (const [key, value] of Object.entries(params)) {
6932
+ if (value !== undefined && value !== null && value !== "")
6933
+ url.searchParams.set(key, String(value));
6934
+ }
6935
+ const response = await fetch(url, { headers: { Authorization: `Bearer ${token}`, Accept: "application/json" } });
6936
+ if (!response.ok) {
6937
+ const body = await response.text().catch(() => "");
6938
+ throw new Error(`Google Drive request failed (${response.status}): ${extractGoogleError(body) || response.statusText}`);
6939
+ }
6940
+ return response;
6941
+ }
6942
+ async function getValidAccessToken(profile) {
6943
+ if (process.env.GOOGLE_ACCESS_TOKEN)
6944
+ return process.env.GOOGLE_ACCESS_TOKEN;
6945
+ const tokens = loadTokens(profile);
6946
+ if (!tokens?.accessToken && !tokens?.refreshToken) {
6947
+ throw new Error(`Google Drive profile "${profile}" is not authenticated. Run: connectors auth googledrive`);
6948
+ }
6949
+ if (tokens.accessToken && (!tokens.expiresAt || Date.now() < tokens.expiresAt - REFRESH_BUFFER_MS))
6950
+ return tokens.accessToken;
6951
+ if (!tokens.refreshToken)
6952
+ return tokens.accessToken ?? "";
6953
+ return (await refreshAccessToken(profile, tokens)).accessToken ?? "";
6954
+ }
6955
+ async function refreshAccessToken(profile, currentTokens) {
6956
+ const credentials = loadCredentials(profile);
6957
+ if (!credentials.clientId || !credentials.clientSecret)
6958
+ throw new Error("Google Drive OAuth credentials are not configured. Run: connectors auth googledrive");
6959
+ if (!currentTokens.refreshToken)
6960
+ throw new Error(`Google Drive profile "${profile}" has no refresh token. Run: connectors auth googledrive`);
6961
+ const response = await fetch(TOKEN_URL, {
6962
+ method: "POST",
6963
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
6964
+ body: new URLSearchParams({
6965
+ client_id: credentials.clientId,
6966
+ client_secret: credentials.clientSecret,
6967
+ refresh_token: currentTokens.refreshToken,
6968
+ grant_type: "refresh_token"
6969
+ })
6970
+ });
6971
+ const data = await response.json().catch(() => ({}));
6972
+ if (!response.ok || !data.access_token)
6973
+ throw new Error(`Google Drive token refresh failed: ${data.error_description || data.error || response.statusText}`);
6974
+ const tokens = {
6975
+ accessToken: data.access_token,
6976
+ refreshToken: currentTokens.refreshToken,
6977
+ expiresAt: Date.now() + (data.expires_in ?? 3600) * 1000,
6978
+ tokenType: data.token_type ?? currentTokens.tokenType,
6979
+ scope: data.scope ?? currentTokens.scope
6980
+ };
6981
+ saveTokens(profile, tokens);
6982
+ return tokens;
6983
+ }
6984
+ function listProfiles() {
6985
+ const profiles = new Set;
6986
+ for (const baseDir of configDirs()) {
6987
+ const profilesDir = join2(baseDir, "profiles");
6988
+ if (!existsSync2(profilesDir))
6989
+ continue;
6990
+ for (const entry of readdirSync(profilesDir, { withFileTypes: true })) {
6991
+ if (entry.isDirectory())
6992
+ profiles.add(entry.name);
6993
+ if (entry.isFile() && entry.name.endsWith(".json"))
6994
+ profiles.add(basename(entry.name, ".json"));
6995
+ }
6996
+ }
6997
+ return Array.from(profiles).sort((a, b) => a.localeCompare(b));
6998
+ }
6999
+ function loadCredentials(profile) {
7000
+ const envClientId = process.env.GOOGLE_CLIENT_ID;
7001
+ const envClientSecret = process.env.GOOGLE_CLIENT_SECRET;
7002
+ if (envClientId && envClientSecret)
7003
+ return { clientId: envClientId, clientSecret: envClientSecret };
7004
+ for (const baseDir of configDirs()) {
7005
+ const credentials = {
7006
+ ...readJson(join2(baseDir, "credentials.json")),
7007
+ ...readJson(join2(baseDir, "profiles", profile, "config.json"))
7008
+ };
7009
+ if (credentials.clientId || credentials.clientSecret)
7010
+ return credentials;
7011
+ }
7012
+ return {};
7013
+ }
7014
+ function loadTokens(profile) {
7015
+ for (const baseDir of configDirs()) {
7016
+ const fromProfile = readJson(join2(baseDir, "profiles", profile, "tokens.json"));
7017
+ if (fromProfile)
7018
+ return fromProfile;
7019
+ const flat = readJson(join2(baseDir, "profiles", `${profile}.json`));
7020
+ if (flat)
7021
+ return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
7022
+ }
7023
+ return null;
7024
+ }
7025
+ function saveTokens(profile, tokens) {
7026
+ const baseDir = configDirs().find((dir) => existsSync2(dir)) ?? configDirs()[0];
7027
+ const profileDir = join2(baseDir, "profiles", profile);
7028
+ mkdirSync(profileDir, { recursive: true });
7029
+ writeFileSync(join2(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
7030
+ }
7031
+ function configDirs() {
7032
+ const explicit = process.env.HASNA_GOOGLE_DRIVE_CONNECTOR_DIR ?? process.env.GOOGLE_DRIVE_CONNECTOR_DIR;
7033
+ if (explicit)
7034
+ return [explicit];
7035
+ const baseDir = process.env.HASNA_CONNECTORS_DIR ?? join2(homedir(), ".hasna", "connectors");
7036
+ return [join2(baseDir, "connect-googledrive"), join2(baseDir, "googledrive")];
7037
+ }
7038
+ function readJson(path) {
7039
+ if (!existsSync2(path))
7040
+ return null;
7041
+ try {
7042
+ return JSON.parse(readFileSync(path, "utf8"));
7043
+ } catch {
7044
+ return null;
7045
+ }
7046
+ }
7047
+ function defaultExportMimeType(googleMimeType) {
7048
+ if (googleMimeType.endsWith(".document"))
7049
+ return DEFAULT_EXPORT_FORMATS.document;
7050
+ if (googleMimeType.endsWith(".spreadsheet"))
7051
+ return DEFAULT_EXPORT_FORMATS.spreadsheet;
7052
+ if (googleMimeType.endsWith(".presentation"))
7053
+ return DEFAULT_EXPORT_FORMATS.presentation;
7054
+ if (googleMimeType.endsWith(".drawing"))
7055
+ return DEFAULT_EXPORT_FORMATS.drawing;
7056
+ throw new Error(`Cannot export Google Workspace file type: ${googleMimeType}`);
7057
+ }
7058
+ function extensionForMimeType(mimeType) {
7059
+ return EXPORT_EXTENSIONS[mimeType] ?? "";
7060
+ }
7061
+ function extractGoogleError(body) {
7062
+ if (!body)
7063
+ return "";
7064
+ try {
7065
+ const parsed = JSON.parse(body);
7066
+ return parsed.error?.message ?? body;
7067
+ } catch {
7068
+ return body;
7069
+ }
7070
+ }
7071
+ var DRIVE_API_BASE = "https://www.googleapis.com/drive/v3", TOKEN_URL = "https://oauth2.googleapis.com/token", REFRESH_BUFFER_MS, DEFAULT_FILE_FIELDS, DEFAULT_EXPORT_FORMATS, EXPORT_EXTENSIONS, listFilesSchema, listDrivesSchema, fileIdSchema, downloadSchema, googleDriveConnector;
7072
+ var init_googledrive = __esm(() => {
7073
+ init_zod();
7074
+ init_connector();
7075
+ REFRESH_BUFFER_MS = 5 * 60 * 1000;
7076
+ DEFAULT_FILE_FIELDS = [
7077
+ "id",
7078
+ "name",
7079
+ "mimeType",
7080
+ "parents",
7081
+ "version",
7082
+ "md5Checksum",
7083
+ "size",
7084
+ "modifiedTime",
7085
+ "createdTime",
7086
+ "trashed",
7087
+ "webViewLink",
7088
+ "webContentLink"
7089
+ ].join(",");
7090
+ DEFAULT_EXPORT_FORMATS = {
7091
+ document: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
7092
+ spreadsheet: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
7093
+ presentation: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
7094
+ drawing: "image/png"
7095
+ };
7096
+ EXPORT_EXTENSIONS = {
7097
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ".docx",
7098
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ".xlsx",
7099
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": ".pptx",
7100
+ "application/pdf": ".pdf",
7101
+ "text/plain": ".txt",
7102
+ "text/csv": ".csv",
7103
+ "image/png": ".png",
7104
+ "image/jpeg": ".jpg",
7105
+ "image/svg+xml": ".svg"
7106
+ };
7107
+ listFilesSchema = exports_external.object({
7108
+ pageSize: exports_external.coerce.number().int().positive().max(1000).optional(),
7109
+ pageToken: exports_external.string().optional(),
7110
+ q: exports_external.string().optional(),
7111
+ fields: exports_external.string().optional(),
7112
+ orderBy: exports_external.string().optional(),
7113
+ corpora: exports_external.enum(["user", "drive", "allDrives"]).optional(),
7114
+ driveId: exports_external.string().optional(),
7115
+ supportsAllDrives: exports_external.boolean().optional(),
7116
+ includeItemsFromAllDrives: exports_external.boolean().optional()
7117
+ });
7118
+ listDrivesSchema = exports_external.object({
7119
+ pageSize: exports_external.coerce.number().int().positive().max(100).optional(),
7120
+ pageToken: exports_external.string().optional(),
7121
+ q: exports_external.string().optional()
7122
+ });
7123
+ fileIdSchema = exports_external.object({
7124
+ fileId: exports_external.string(),
7125
+ fields: exports_external.string().optional()
7126
+ });
7127
+ downloadSchema = exports_external.object({
7128
+ fileId: exports_external.string(),
7129
+ file: exports_external.object({
7130
+ id: exports_external.string(),
7131
+ name: exports_external.string(),
7132
+ mimeType: exports_external.string()
7133
+ }).optional(),
7134
+ exportMimeType: exports_external.string().optional()
7135
+ });
7136
+ googleDriveConnector = defineConnector({
7137
+ meta: {
7138
+ name: "googledrive",
7139
+ displayName: "Google Drive",
7140
+ description: "Profile-aware Google Drive discovery and file download operations.",
7141
+ category: "storage",
7142
+ tags: ["google", "drive", "files", "storage"]
7143
+ },
7144
+ auth: {
7145
+ type: "oauth2",
7146
+ supportsProfiles: true,
7147
+ fields: [
7148
+ { key: "clientId", env: "GOOGLE_CLIENT_ID", label: "OAuth client ID" },
7149
+ { key: "clientSecret", env: "GOOGLE_CLIENT_SECRET", label: "OAuth client secret", secret: true }
7150
+ ]
7151
+ },
7152
+ createContext: ({ profile }) => ({ profile: profile || "default" }),
7153
+ operations: {
7154
+ "profiles.list": {
7155
+ summary: "List configured Google Drive profiles.",
7156
+ execute: () => ({ profiles: listProfiles() })
7157
+ },
7158
+ "files.list": {
7159
+ summary: "List Google Drive files.",
7160
+ inputSchema: listFilesSchema,
7161
+ execute: async ({ context }, input) => requestJson(context.profile, "/files", {
7162
+ pageSize: input.pageSize ?? 1000,
7163
+ pageToken: input.pageToken,
7164
+ q: input.q,
7165
+ fields: input.fields ?? `nextPageToken,files(${DEFAULT_FILE_FIELDS})`,
7166
+ orderBy: input.orderBy ?? "modifiedTime desc",
7167
+ corpora: input.corpora,
7168
+ driveId: input.driveId,
7169
+ supportsAllDrives: input.supportsAllDrives ?? true,
7170
+ includeItemsFromAllDrives: input.includeItemsFromAllDrives ?? false
7171
+ })
7172
+ },
7173
+ "files.get": {
7174
+ summary: "Get Google Drive file metadata.",
7175
+ inputSchema: fileIdSchema,
7176
+ execute: async ({ context }, input) => requestJson(context.profile, `/files/${encodeURIComponent(input.fileId)}`, {
7177
+ fields: input.fields ?? DEFAULT_FILE_FIELDS,
7178
+ supportsAllDrives: true
7179
+ })
7180
+ },
7181
+ "files.download": {
7182
+ summary: "Download or export a Google Drive file as base64 content.",
7183
+ inputSchema: downloadSchema,
7184
+ execute: async ({ context }, input) => {
7185
+ const file = input.file ?? await requestJson(context.profile, `/files/${encodeURIComponent(input.fileId)}`, { fields: DEFAULT_FILE_FIELDS, supportsAllDrives: true });
7186
+ const exportMimeType = file.mimeType.startsWith("application/vnd.google-apps.") ? input.exportMimeType ?? defaultExportMimeType(file.mimeType) : undefined;
7187
+ const data = await requestBinary(context.profile, exportMimeType ? `/files/${encodeURIComponent(file.id)}/export` : `/files/${encodeURIComponent(file.id)}`, exportMimeType ? { mimeType: exportMimeType, supportsAllDrives: true } : { alt: "media", supportsAllDrives: true });
7188
+ const mimeType = exportMimeType ?? file.mimeType ?? "application/octet-stream";
7189
+ return {
7190
+ dataBase64: Buffer.from(data).toString("base64"),
7191
+ filename: exportMimeType ? `${file.name}${extensionForMimeType(exportMimeType)}` : file.name,
7192
+ mimeType
7193
+ };
7194
+ }
7195
+ },
7196
+ "drives.list": {
7197
+ summary: "List Google shared drives.",
7198
+ inputSchema: listDrivesSchema,
7199
+ execute: async ({ context }, input) => requestJson(context.profile, "/drives", {
7200
+ pageSize: input.pageSize ?? 100,
7201
+ pageToken: input.pageToken,
7202
+ q: input.q
7203
+ })
7204
+ }
7205
+ }
7206
+ });
7207
+ });
7208
+
7209
+ // node_modules/@hasna/cloud/dist/index.js
6917
7210
  var exports_dist = {};
6918
7211
  __export(exports_dist, {
6919
7212
  translateSql: () => translateSql,
@@ -6986,27 +7279,27 @@ __export(exports_dist, {
6986
7279
  import { createRequire } from "module";
6987
7280
  import { Database } from "bun:sqlite";
6988
7281
  import {
6989
- existsSync as existsSync2,
6990
- mkdirSync,
6991
- readdirSync,
7282
+ existsSync as existsSync3,
7283
+ mkdirSync as mkdirSync2,
7284
+ readdirSync as readdirSync2,
6992
7285
  copyFileSync
6993
7286
  } from "fs";
6994
- import { homedir } from "os";
6995
- import { join as join2, relative } from "path";
6996
- import { existsSync as existsSync22, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
6997
7287
  import { homedir as homedir2 } from "os";
7288
+ import { join as join3, relative } from "path";
7289
+ import { existsSync as existsSync22, mkdirSync as mkdirSync22, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
7290
+ import { homedir as homedir22 } from "os";
6998
7291
  import { join as join22 } from "path";
6999
- import { readdirSync as readdirSync2, existsSync as existsSync3 } from "fs";
7000
- import { join as join3 } from "path";
7292
+ import { readdirSync as readdirSync22, existsSync as existsSync32 } from "fs";
7293
+ import { join as join32 } from "path";
7001
7294
  import { homedir as homedir3 } from "os";
7002
7295
  import { hostname } from "os";
7003
- import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
7296
+ import { existsSync as existsSync4, readFileSync as readFileSync22 } from "fs";
7004
7297
  import { homedir as homedir4 } from "os";
7005
7298
  import { join as join4 } from "path";
7006
7299
  import { existsSync as existsSync5, readdirSync as readdirSync3 } from "fs";
7007
7300
  import { join as join5 } from "path";
7008
7301
  import { join as join6, dirname as dirname2 } from "path";
7009
- import { existsSync as existsSync6, writeFileSync as writeFileSync2, unlinkSync, mkdirSync as mkdirSync3 } from "fs";
7302
+ import { existsSync as existsSync6, writeFileSync as writeFileSync22, unlinkSync, mkdirSync as mkdirSync3 } from "fs";
7010
7303
  import { homedir as homedir5, platform } from "os";
7011
7304
  function __accessProp2(key) {
7012
7305
  return this[key];
@@ -7889,33 +8182,33 @@ function custom2(check, _params = {}, fatal) {
7889
8182
  return ZodAny2.create();
7890
8183
  }
7891
8184
  function getDataDir(serviceName) {
7892
- const dir = join2(HASNA_DIR, serviceName);
7893
- mkdirSync(dir, { recursive: true });
8185
+ const dir = join3(HASNA_DIR, serviceName);
8186
+ mkdirSync2(dir, { recursive: true });
7894
8187
  return dir;
7895
8188
  }
7896
8189
  function getDbPath(serviceName) {
7897
8190
  const dir = getDataDir(serviceName);
7898
- return join2(dir, `${serviceName}.db`);
8191
+ return join3(dir, `${serviceName}.db`);
7899
8192
  }
7900
8193
  function migrateDotfile(serviceName) {
7901
- const legacyDir = join2(homedir(), `.${serviceName}`);
7902
- const newDir = join2(HASNA_DIR, serviceName);
7903
- if (!existsSync2(legacyDir))
8194
+ const legacyDir = join3(homedir2(), `.${serviceName}`);
8195
+ const newDir = join3(HASNA_DIR, serviceName);
8196
+ if (!existsSync3(legacyDir))
7904
8197
  return [];
7905
- if (existsSync2(newDir))
8198
+ if (existsSync3(newDir))
7906
8199
  return [];
7907
- mkdirSync(newDir, { recursive: true });
8200
+ mkdirSync2(newDir, { recursive: true });
7908
8201
  const migrated = [];
7909
8202
  copyDirRecursive(legacyDir, newDir, legacyDir, migrated);
7910
8203
  return migrated;
7911
8204
  }
7912
8205
  function copyDirRecursive(src, dest, root, migrated) {
7913
- const entries = readdirSync(src, { withFileTypes: true });
8206
+ const entries = readdirSync2(src, { withFileTypes: true });
7914
8207
  for (const entry of entries) {
7915
- const srcPath = join2(src, entry.name);
7916
- const destPath = join2(dest, entry.name);
8208
+ const srcPath = join3(src, entry.name);
8209
+ const destPath = join3(dest, entry.name);
7917
8210
  if (entry.isDirectory()) {
7918
- mkdirSync(destPath, { recursive: true });
8211
+ mkdirSync2(destPath, { recursive: true });
7919
8212
  copyDirRecursive(srcPath, destPath, root, migrated);
7920
8213
  } else {
7921
8214
  copyFileSync(srcPath, destPath);
@@ -7924,10 +8217,10 @@ function copyDirRecursive(src, dest, root, migrated) {
7924
8217
  }
7925
8218
  }
7926
8219
  function hasLegacyDotfile(serviceName) {
7927
- return existsSync2(join2(homedir(), `.${serviceName}`));
8220
+ return existsSync3(join3(homedir2(), `.${serviceName}`));
7928
8221
  }
7929
8222
  function getHasnaDir() {
7930
- mkdirSync(HASNA_DIR, { recursive: true });
8223
+ mkdirSync2(HASNA_DIR, { recursive: true });
7931
8224
  return HASNA_DIR;
7932
8225
  }
7933
8226
  function getConfigDir() {
@@ -7941,15 +8234,15 @@ function getCloudConfig() {
7941
8234
  return CloudConfigSchema.parse({});
7942
8235
  }
7943
8236
  try {
7944
- const raw = readFileSync(CONFIG_PATH, "utf-8");
8237
+ const raw = readFileSync2(CONFIG_PATH, "utf-8");
7945
8238
  return CloudConfigSchema.parse(JSON.parse(raw));
7946
8239
  } catch {
7947
8240
  return CloudConfigSchema.parse({});
7948
8241
  }
7949
8242
  }
7950
8243
  function saveCloudConfig(config) {
7951
- mkdirSync2(CONFIG_DIR, { recursive: true });
7952
- writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + `
8244
+ mkdirSync22(CONFIG_DIR, { recursive: true });
8245
+ writeFileSync2(CONFIG_PATH, JSON.stringify(config, null, 2) + `
7953
8246
  `, "utf-8");
7954
8247
  }
7955
8248
  function getConnectionString(dbName) {
@@ -7979,11 +8272,11 @@ function isSyncExcludedTable(table) {
7979
8272
  return SYNC_EXCLUDED_TABLE_PATTERNS.some((p) => p.test(table));
7980
8273
  }
7981
8274
  function discoverServices() {
7982
- const dataDir = join3(homedir3(), ".hasna");
7983
- if (!existsSync3(dataDir))
8275
+ const dataDir = join32(homedir3(), ".hasna");
8276
+ if (!existsSync32(dataDir))
7984
8277
  return [];
7985
8278
  try {
7986
- const entries = readdirSync2(dataDir, { withFileTypes: true });
8279
+ const entries = readdirSync22(dataDir, { withFileTypes: true });
7987
8280
  return entries.filter((e) => {
7988
8281
  if (!e.isDirectory())
7989
8282
  return false;
@@ -8001,24 +8294,24 @@ function discoverSyncableServices() {
8001
8294
  return local.filter((s) => pgSet.has(s));
8002
8295
  }
8003
8296
  function getServiceDbPath(service) {
8004
- const dataDir = join3(homedir3(), ".hasna", service);
8005
- if (!existsSync3(dataDir))
8297
+ const dataDir = join32(homedir3(), ".hasna", service);
8298
+ if (!existsSync32(dataDir))
8006
8299
  return null;
8007
8300
  const candidates = [
8008
- join3(dataDir, `${service}.db`),
8009
- join3(dataDir, "data.db"),
8010
- join3(dataDir, "database.db")
8301
+ join32(dataDir, `${service}.db`),
8302
+ join32(dataDir, "data.db"),
8303
+ join32(dataDir, "database.db")
8011
8304
  ];
8012
8305
  try {
8013
- const files = readdirSync2(dataDir);
8306
+ const files = readdirSync22(dataDir);
8014
8307
  for (const f of files) {
8015
8308
  if (f.endsWith(".db") && !f.endsWith("-wal") && !f.endsWith("-shm")) {
8016
- candidates.push(join3(dataDir, f));
8309
+ candidates.push(join32(dataDir, f));
8017
8310
  }
8018
8311
  }
8019
8312
  } catch {}
8020
8313
  for (const p of candidates) {
8021
- if (existsSync3(p))
8314
+ if (existsSync32(p))
8022
8315
  return p;
8023
8316
  }
8024
8317
  return null;
@@ -8940,7 +9233,7 @@ function getAutoSyncConfig() {
8940
9233
  if (!existsSync4(AUTO_SYNC_CONFIG_PATH)) {
8941
9234
  return { ...DEFAULT_AUTO_SYNC_CONFIG };
8942
9235
  }
8943
- const raw = JSON.parse(readFileSync2(AUTO_SYNC_CONFIG_PATH, "utf-8"));
9236
+ const raw = JSON.parse(readFileSync22(AUTO_SYNC_CONFIG_PATH, "utf-8"));
8944
9237
  return {
8945
9238
  auto_sync_on_start: typeof raw.auto_sync_on_start === "boolean" ? raw.auto_sync_on_start : DEFAULT_AUTO_SYNC_CONFIG.auto_sync_on_start,
8946
9239
  auto_sync_on_stop: typeof raw.auto_sync_on_stop === "boolean" ? raw.auto_sync_on_stop : DEFAULT_AUTO_SYNC_CONFIG.auto_sync_on_stop
@@ -9229,7 +9522,7 @@ async function registerLaunchd(intervalMinutes) {
9229
9522
  try {
9230
9523
  await Bun.spawn(["launchctl", "unload", plistPath]).exited;
9231
9524
  } catch {}
9232
- writeFileSync2(plistPath, createLaunchdPlist(intervalMinutes));
9525
+ writeFileSync22(plistPath, createLaunchdPlist(intervalMinutes));
9233
9526
  await Bun.spawn(["launchctl", "load", plistPath]).exited;
9234
9527
  }
9235
9528
  async function removeLaunchd() {
@@ -9277,8 +9570,8 @@ WantedBy=timers.target
9277
9570
  async function registerSystemd(intervalMinutes) {
9278
9571
  const dir = getSystemdDir();
9279
9572
  mkdirSync3(dir, { recursive: true });
9280
- writeFileSync2(join6(dir, `${SERVICE_NAME}.service`), createSystemdService());
9281
- writeFileSync2(join6(dir, `${SERVICE_NAME}.timer`), createSystemdTimer(intervalMinutes));
9573
+ writeFileSync22(join6(dir, `${SERVICE_NAME}.service`), createSystemdService());
9574
+ writeFileSync22(join6(dir, `${SERVICE_NAME}.timer`), createSystemdTimer(intervalMinutes));
9282
9575
  await Bun.spawn(["systemctl", "--user", "daemon-reload"]).exited;
9283
9576
  await Bun.spawn(["systemctl", "--user", "enable", "--now", `${SERVICE_NAME}.timer`]).exited;
9284
9577
  }
@@ -17875,7 +18168,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
17875
18168
  init_external2();
17876
18169
  });
17877
18170
  init_dotfile = __esm2(() => {
17878
- HASNA_DIR = join2(homedir(), ".hasna");
18171
+ HASNA_DIR = join3(homedir2(), ".hasna");
17879
18172
  });
17880
18173
  exports_config = {};
17881
18174
  __export2(exports_config, {
@@ -17906,7 +18199,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
17906
18199
  schedule_minutes: exports_external2.number().default(0)
17907
18200
  }).default({})
17908
18201
  });
17909
- CONFIG_DIR = join22(homedir2(), ".hasna", "cloud");
18202
+ CONFIG_DIR = join22(homedir22(), ".hasna", "cloud");
17910
18203
  CONFIG_PATH = join22(CONFIG_DIR, "config.json");
17911
18204
  });
17912
18205
  exports_discover = {};
@@ -18299,7 +18592,7 @@ function profileExists(profile) {
18299
18592
  }
18300
18593
  return existsSync9(getFlatProfilePath(profile)) || existsSync9(join9(getProfilesDir(), profile));
18301
18594
  }
18302
- function listProfiles() {
18595
+ function listProfiles2() {
18303
18596
  const profilesDir = getProfilesDir();
18304
18597
  const seen = new Set(["default"]);
18305
18598
  if (!existsSync9(profilesDir)) {
@@ -18742,7 +19035,7 @@ async function runProfileCommand2(args, context) {
18742
19035
  switch (subcommand) {
18743
19036
  case "list": {
18744
19037
  const current = getCurrentProfile();
18745
- const profiles = listProfiles();
19038
+ const profiles = listProfiles2();
18746
19039
  return successOutput({ current, profiles }, context.format, () => profiles.map((profile) => `${profile}${profile === current ? " (active)" : ""}`).join(`
18747
19040
  `));
18748
19041
  }
@@ -20138,10 +20431,12 @@ var INTERNAL_CONNECTOR_DEFINITIONS, INTERNAL_CONNECTOR_REGISTRY;
20138
20431
  var init_builtins = __esm(() => {
20139
20432
  init_registry();
20140
20433
  init_github();
20434
+ init_googledrive();
20141
20435
  init_imessage();
20142
20436
  init_stripe();
20143
20437
  INTERNAL_CONNECTOR_DEFINITIONS = [
20144
20438
  githubConnector,
20439
+ googleDriveConnector,
20145
20440
  imessageConnector,
20146
20441
  stripeConnector
20147
20442
  ];
@@ -26281,7 +26576,7 @@ __export(exports_registry, {
26281
26576
  CONNECTORS: () => CONNECTORS,
26282
26577
  CATEGORIES: () => CATEGORIES
26283
26578
  });
26284
- import { existsSync as existsSync11, readFileSync as readFileSync5 } from "fs";
26579
+ import { existsSync as existsSync11, readFileSync as readFileSync4 } from "fs";
26285
26580
  import { join as join11, dirname as dirname5 } from "path";
26286
26581
  import { fileURLToPath as fileURLToPath3 } from "url";
26287
26582
  function getConnectorsByCategory(category) {
@@ -26453,7 +26748,7 @@ function loadConnectorVersions() {
26453
26748
  try {
26454
26749
  const pkgPath = join11(connectorsDir, `connect-${connector.name}`, "package.json");
26455
26750
  if (existsSync11(pkgPath)) {
26456
- const pkg = JSON.parse(readFileSync5(pkgPath, "utf-8"));
26751
+ const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
26457
26752
  connector.version = pkg.version || "0.0.0";
26458
26753
  continue;
26459
26754
  }
@@ -26525,7 +26820,7 @@ var init_registry2 = __esm(() => {
26525
26820
  ];
26526
26821
  });
26527
26822
 
26528
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/cli-spinners/spinners.json
26823
+ // node_modules/cli-spinners/spinners.json
26529
26824
  var require_spinners = __commonJS((exports, module) => {
26530
26825
  module.exports = {
26531
26826
  dots: {
@@ -28151,7 +28446,7 @@ var require_spinners = __commonJS((exports, module) => {
28151
28446
  };
28152
28447
  });
28153
28448
 
28154
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/cli-spinners/index.js
28449
+ // node_modules/cli-spinners/index.js
28155
28450
  var require_cli_spinners = __commonJS((exports, module) => {
28156
28451
  var spinners = Object.assign({}, require_spinners());
28157
28452
  var spinnersList = Object.keys(spinners);
@@ -28176,7 +28471,7 @@ __export(exports_installer, {
28176
28471
  getConnectorDocs: () => getConnectorDocs,
28177
28472
  connectorExists: () => connectorExists
28178
28473
  });
28179
- import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5, readdirSync as readdirSync7, statSync as statSync3, rmSync as rmSync2 } from "fs";
28474
+ import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync4, readdirSync as readdirSync7, statSync as statSync3, rmSync as rmSync2 } from "fs";
28180
28475
  import { join as join12, dirname as dirname6 } from "path";
28181
28476
  import { fileURLToPath as fileURLToPath4 } from "url";
28182
28477
  function resolveConnectorsDir() {
@@ -28206,7 +28501,7 @@ function loadEnablementManifest(targetDir) {
28206
28501
  return null;
28207
28502
  }
28208
28503
  try {
28209
- const raw = JSON.parse(readFileSync6(manifestPath, "utf-8"));
28504
+ const raw = JSON.parse(readFileSync5(manifestPath, "utf-8"));
28210
28505
  if (!Array.isArray(raw.connectors)) {
28211
28506
  return null;
28212
28507
  }
@@ -28251,7 +28546,7 @@ ${connectorList}
28251
28546
 
28252
28547
  export type EnabledConnectorName = typeof enabledConnectors[number];
28253
28548
  `;
28254
- writeFileSync5(indexPath, content);
28549
+ writeFileSync4(indexPath, content);
28255
28550
  }
28256
28551
  function writeEnablementManifest(targetDir, connectors18) {
28257
28552
  const connectorsDir = getProjectConnectorsDir(targetDir);
@@ -28262,7 +28557,7 @@ function writeEnablementManifest(targetDir, connectors18) {
28262
28557
  updatedAt: new Date().toISOString(),
28263
28558
  connectors: [...new Set(connectors18.map((value) => normalizeConnectorName(value)))].sort()
28264
28559
  };
28265
- writeFileSync5(getEnablementManifestPath(targetDir), JSON.stringify(manifest, null, 2) + `
28560
+ writeFileSync4(getEnablementManifestPath(targetDir), JSON.stringify(manifest, null, 2) + `
28266
28561
  `);
28267
28562
  updateConnectorsIndex(connectorsDir, manifest.connectors);
28268
28563
  }
@@ -28342,7 +28637,7 @@ function getConnectorDocs(name) {
28342
28637
  const connectorPath = getConnectorPath(normalizedName);
28343
28638
  const claudeMdPath = join12(connectorPath, "CLAUDE.md");
28344
28639
  if (existsSync12(claudeMdPath)) {
28345
- return parseConnectorDocs(readFileSync6(claudeMdPath, "utf-8"));
28640
+ return parseConnectorDocs(readFileSync5(claudeMdPath, "utf-8"));
28346
28641
  }
28347
28642
  const internalDocs = getInternalConnectorDefinition(normalizedName)?.docsMarkdown;
28348
28643
  if (internalDocs) {
@@ -28465,7 +28760,7 @@ var init_lock = __esm(() => {
28465
28760
  });
28466
28761
 
28467
28762
  // src/server/auth.ts
28468
- import { existsSync as existsSync14, readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync9, readdirSync as readdirSync9, rmSync as rmSync3, statSync as statSync6 } from "fs";
28763
+ import { existsSync as existsSync14, readFileSync as readFileSync6, writeFileSync as writeFileSync5, mkdirSync as mkdirSync9, readdirSync as readdirSync9, rmSync as rmSync3, statSync as statSync6 } from "fs";
28469
28764
  import { randomBytes } from "crypto";
28470
28765
  import { join as join15 } from "path";
28471
28766
  function getAuthType(name) {
@@ -28488,7 +28783,7 @@ function getCurrentProfile2(name) {
28488
28783
  const currentProfileFile = join15(configDir, "current_profile");
28489
28784
  if (existsSync14(currentProfileFile)) {
28490
28785
  try {
28491
- return readFileSync7(currentProfileFile, "utf-8").trim() || "default";
28786
+ return readFileSync6(currentProfileFile, "utf-8").trim() || "default";
28492
28787
  } catch {
28493
28788
  return "default";
28494
28789
  }
@@ -28503,13 +28798,13 @@ function loadProfileConfig(name) {
28503
28798
  const profileFile = join15(configDir, "profiles", `${profile}.json`);
28504
28799
  if (existsSync14(profileFile)) {
28505
28800
  try {
28506
- flatConfig = JSON.parse(readFileSync7(profileFile, "utf-8"));
28801
+ flatConfig = JSON.parse(readFileSync6(profileFile, "utf-8"));
28507
28802
  } catch {}
28508
28803
  }
28509
28804
  const profileDirConfig = join15(configDir, "profiles", profile, "config.json");
28510
28805
  if (existsSync14(profileDirConfig)) {
28511
28806
  try {
28512
- dirConfig = JSON.parse(readFileSync7(profileDirConfig, "utf-8"));
28807
+ dirConfig = JSON.parse(readFileSync6(profileDirConfig, "utf-8"));
28513
28808
  } catch {}
28514
28809
  }
28515
28810
  if (Object.keys(flatConfig).length === 0 && Object.keys(dirConfig).length === 0) {
@@ -28517,13 +28812,13 @@ function loadProfileConfig(name) {
28517
28812
  }
28518
28813
  return { ...flatConfig, ...dirConfig };
28519
28814
  }
28520
- function loadTokens(name) {
28815
+ function loadTokens2(name) {
28521
28816
  const configDir = getConnectorConfigDir(name);
28522
28817
  const profile = getCurrentProfile2(name);
28523
28818
  const tokensFile = join15(configDir, "profiles", profile, "tokens.json");
28524
28819
  if (existsSync14(tokensFile)) {
28525
28820
  try {
28526
- return JSON.parse(readFileSync7(tokensFile, "utf-8"));
28821
+ return JSON.parse(readFileSync6(tokensFile, "utf-8"));
28527
28822
  } catch {
28528
28823
  return null;
28529
28824
  }
@@ -28540,28 +28835,49 @@ function loadTokens(name) {
28540
28835
  }
28541
28836
  return null;
28542
28837
  }
28838
+ function isStoredOAuthEnvVarSet(variable, oauthConfig, tokens, profileConfig) {
28839
+ if (variable.endsWith("_CLIENT_ID")) {
28840
+ return Boolean(oauthConfig.clientId || profileConfig.clientId);
28841
+ }
28842
+ if (variable.endsWith("_CLIENT_SECRET")) {
28843
+ return Boolean(oauthConfig.clientSecret || profileConfig.clientSecret);
28844
+ }
28845
+ if (variable.endsWith("_ACCESS_TOKEN")) {
28846
+ return Boolean(tokens?.accessToken || profileConfig.accessToken);
28847
+ }
28848
+ if (variable.endsWith("_REFRESH_TOKEN")) {
28849
+ return Boolean(tokens?.refreshToken || profileConfig.refreshToken);
28850
+ }
28851
+ if (variable.endsWith("_TOKEN_EXPIRES_AT")) {
28852
+ return Boolean(tokens?.expiresAt || profileConfig.expiresAt);
28853
+ }
28854
+ return false;
28855
+ }
28543
28856
  function getAuthStatus(name) {
28544
28857
  const authType = getAuthType(name);
28545
28858
  const docs = getConnectorDocs(name);
28859
+ const oauthConfig = authType === "oauth" ? getOAuthConfig(name) : {};
28860
+ const tokens = authType === "oauth" ? loadTokens2(name) : null;
28861
+ const profileConfig = authType === "oauth" ? loadProfileConfig(name) : {};
28546
28862
  const envVars = (docs?.envVars || []).map((v) => ({
28547
28863
  variable: v.variable,
28548
28864
  description: v.description,
28549
- set: !!process.env[v.variable]
28865
+ set: !!process.env[v.variable] || authType === "oauth" && isStoredOAuthEnvVarSet(v.variable, oauthConfig, tokens, profileConfig)
28550
28866
  }));
28551
28867
  const envVarTotalCount = envVars.length;
28552
28868
  const envVarSetCount = envVars.filter((v) => v.set).length;
28553
28869
  if (authType === "oauth") {
28554
- const tokens = loadTokens(name);
28555
- const config2 = loadProfileConfig(name);
28556
- const hasTokens = !!tokens?.accessToken || !!config2.accessToken;
28557
- const hasRefreshToken = !!tokens?.refreshToken || !!config2.refreshToken;
28558
- const tokenExpiry = tokens?.expiresAt || config2.expiresAt;
28870
+ const hasTokens = !!tokens?.accessToken || !!profileConfig.accessToken;
28871
+ const hasRefreshToken = !!tokens?.refreshToken || !!profileConfig.refreshToken;
28872
+ const tokenExpiry = tokens?.expiresAt || profileConfig.expiresAt;
28873
+ const hasOAuthCredentials = Boolean(oauthConfig.clientId && oauthConfig.clientSecret);
28559
28874
  const hasEnvVar2 = envVars.some((v) => v.set);
28560
28875
  return {
28561
28876
  type: "oauth",
28562
- configured: hasTokens || hasRefreshToken || hasEnvVar2,
28877
+ configured: hasTokens || hasRefreshToken || hasOAuthCredentials || hasEnvVar2,
28563
28878
  tokenExpiry,
28564
28879
  hasRefreshToken,
28880
+ hasOAuthCredentials,
28565
28881
  envVars,
28566
28882
  envVarSetCount,
28567
28883
  envVarTotalCount
@@ -28595,11 +28911,11 @@ function _saveApiKey(name, key, field) {
28595
28911
  let creds = {};
28596
28912
  if (existsSync14(credentialsFile)) {
28597
28913
  try {
28598
- creds = JSON.parse(readFileSync7(credentialsFile, "utf-8"));
28914
+ creds = JSON.parse(readFileSync6(credentialsFile, "utf-8"));
28599
28915
  } catch {}
28600
28916
  }
28601
28917
  creds[keyField] = key;
28602
- writeFileSync6(credentialsFile, JSON.stringify(creds, null, 2));
28918
+ writeFileSync5(credentialsFile, JSON.stringify(creds, null, 2));
28603
28919
  return;
28604
28920
  }
28605
28921
  const profileFile = join15(configDir, "profiles", `${profile}.json`);
@@ -28607,10 +28923,10 @@ function _saveApiKey(name, key, field) {
28607
28923
  if (existsSync14(profileFile)) {
28608
28924
  let config = {};
28609
28925
  try {
28610
- config = JSON.parse(readFileSync7(profileFile, "utf-8"));
28926
+ config = JSON.parse(readFileSync6(profileFile, "utf-8"));
28611
28927
  } catch {}
28612
28928
  config[keyField] = key;
28613
- writeFileSync6(profileFile, JSON.stringify(config, null, 2));
28929
+ writeFileSync5(profileFile, JSON.stringify(config, null, 2));
28614
28930
  return;
28615
28931
  }
28616
28932
  if (existsSync14(profileDir)) {
@@ -28618,15 +28934,15 @@ function _saveApiKey(name, key, field) {
28618
28934
  let config = {};
28619
28935
  if (existsSync14(configFile)) {
28620
28936
  try {
28621
- config = JSON.parse(readFileSync7(configFile, "utf-8"));
28937
+ config = JSON.parse(readFileSync6(configFile, "utf-8"));
28622
28938
  } catch {}
28623
28939
  }
28624
28940
  config[keyField] = key;
28625
- writeFileSync6(configFile, JSON.stringify(config, null, 2));
28941
+ writeFileSync5(configFile, JSON.stringify(config, null, 2));
28626
28942
  return;
28627
28943
  }
28628
28944
  mkdirSync9(profileDir, { recursive: true });
28629
- writeFileSync6(join15(profileDir, "config.json"), JSON.stringify({ [keyField]: key }, null, 2));
28945
+ writeFileSync5(join15(profileDir, "config.json"), JSON.stringify({ [keyField]: key }, null, 2));
28630
28946
  }
28631
28947
  function guessKeyField(name) {
28632
28948
  const docs = getConnectorDocs(name);
@@ -28647,7 +28963,7 @@ function getOAuthConfig(name) {
28647
28963
  const credentialsFile = join15(configDir, "credentials.json");
28648
28964
  if (existsSync14(credentialsFile)) {
28649
28965
  try {
28650
- const creds = JSON.parse(readFileSync7(credentialsFile, "utf-8"));
28966
+ const creds = JSON.parse(readFileSync6(credentialsFile, "utf-8"));
28651
28967
  return { clientId: creds.clientId, clientSecret: creds.clientSecret };
28652
28968
  } catch {}
28653
28969
  }
@@ -28729,14 +29045,14 @@ function saveOAuthTokens(name, tokens) {
28729
29045
  const profileDir = join15(configDir, "profiles", profile);
28730
29046
  mkdirSync9(profileDir, { recursive: true });
28731
29047
  const tokensFile = join15(profileDir, "tokens.json");
28732
- writeFileSync6(tokensFile, JSON.stringify(tokens, null, 2), { mode: 384 });
29048
+ writeFileSync5(tokensFile, JSON.stringify(tokens, null, 2), { mode: 384 });
28733
29049
  }
28734
29050
  async function refreshOAuthToken(name) {
28735
29051
  return withWriteLock(name, () => _refreshOAuthToken(name));
28736
29052
  }
28737
29053
  async function _refreshOAuthToken(name) {
28738
29054
  const oauthConfig = getOAuthConfig(name);
28739
- const currentTokens = loadTokens(name);
29055
+ const currentTokens = loadTokens2(name);
28740
29056
  if (!oauthConfig.clientId || !oauthConfig.clientSecret) {
28741
29057
  throw new Error("OAuth credentials not configured for " + name);
28742
29058
  }
@@ -28769,7 +29085,7 @@ async function _refreshOAuthToken(name) {
28769
29085
  saveOAuthTokens(name, tokens);
28770
29086
  return tokens;
28771
29087
  }
28772
- function listProfiles2(name) {
29088
+ function listProfiles3(name) {
28773
29089
  const configDir = getConnectorConfigDir(name);
28774
29090
  const profilesDir = join15(configDir, "profiles");
28775
29091
  if (!existsSync14(profilesDir))
@@ -28793,7 +29109,7 @@ function listProfiles2(name) {
28793
29109
  function switchProfile(name, profile) {
28794
29110
  const configDir = getConnectorConfigDir(name);
28795
29111
  mkdirSync9(configDir, { recursive: true });
28796
- writeFileSync6(join15(configDir, "current_profile"), profile);
29112
+ writeFileSync5(join15(configDir, "current_profile"), profile);
28797
29113
  }
28798
29114
  function deleteProfile2(name, profile) {
28799
29115
  if (profile === "default")
@@ -29072,7 +29388,7 @@ var init_rate = __esm(() => {
29072
29388
  });
29073
29389
 
29074
29390
  // src/lib/llm.ts
29075
- import { existsSync as existsSync15, readFileSync as readFileSync8, writeFileSync as writeFileSync7, mkdirSync as mkdirSync10 } from "fs";
29391
+ import { existsSync as existsSync15, readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync10 } from "fs";
29076
29392
  import { join as join16 } from "path";
29077
29393
  function getLlmConfigPath() {
29078
29394
  return join16(getConnectorsHome(), "llm.json");
@@ -29082,7 +29398,7 @@ function getLlmConfig() {
29082
29398
  if (!existsSync15(path))
29083
29399
  return null;
29084
29400
  try {
29085
- return JSON.parse(readFileSync8(path, "utf-8"));
29401
+ return JSON.parse(readFileSync7(path, "utf-8"));
29086
29402
  } catch {
29087
29403
  return null;
29088
29404
  }
@@ -29090,7 +29406,7 @@ function getLlmConfig() {
29090
29406
  function saveLlmConfig(config) {
29091
29407
  const dir = getConnectorsHome();
29092
29408
  mkdirSync10(dir, { recursive: true });
29093
- writeFileSync7(getLlmConfigPath(), JSON.stringify(config, null, 2));
29409
+ writeFileSync6(getLlmConfigPath(), JSON.stringify(config, null, 2));
29094
29410
  }
29095
29411
  function setLlmStrip(enabled) {
29096
29412
  const config = getLlmConfig();
@@ -29473,7 +29789,7 @@ var init_scheduler = __esm(() => {
29473
29789
  });
29474
29790
 
29475
29791
  // src/lib/workflow-runner.ts
29476
- import { spawn as spawn2 } from "child_process";
29792
+ import { spawn as nodeSpawn } from "child_process";
29477
29793
  async function runStep(step, previousOutput) {
29478
29794
  return new Promise((resolve) => {
29479
29795
  const args = [...step.args ?? []];
@@ -29481,7 +29797,7 @@ async function runStep(step, previousOutput) {
29481
29797
  args.push("--input", previousOutput.trim().slice(0, 4096));
29482
29798
  }
29483
29799
  const cmdArgs = ["run", step.connector, step.command, ...args, "--format", "json"];
29484
- const proc = spawn2("connectors", cmdArgs, { shell: false });
29800
+ const proc = spawnImpl("connectors", cmdArgs, { shell: false });
29485
29801
  let output = "";
29486
29802
  proc.stdout.on("data", (d) => {
29487
29803
  output += d.toString();
@@ -29521,15 +29837,17 @@ async function runWorkflow(workflow) {
29521
29837
  final_output: results[results.length - 1]?.output ?? ""
29522
29838
  };
29523
29839
  }
29840
+ var spawnImpl;
29524
29841
  var init_workflow_runner = __esm(() => {
29525
29842
  init_strip();
29843
+ spawnImpl = nodeSpawn;
29526
29844
  });
29527
29845
 
29528
29846
  // src/lib/runner.ts
29529
29847
  import { existsSync as existsSync16, readdirSync as readdirSync10 } from "fs";
29530
29848
  import { join as join17, dirname as dirname7 } from "path";
29531
29849
  import { fileURLToPath as fileURLToPath5 } from "url";
29532
- import { spawn as spawn3 } from "child_process";
29850
+ import { spawn as spawn2 } from "child_process";
29533
29851
  function resolveConnectorsDir2() {
29534
29852
  const fromBin = join17(__dirname5, "..", "connectors");
29535
29853
  if (existsSync16(fromBin))
@@ -29578,6 +29896,25 @@ function buildEnvWithCredentials(connectorName, baseEnv) {
29578
29896
  }
29579
29897
  }
29580
29898
  }
29899
+ if (getAuthType(connectorName) === "oauth") {
29900
+ const oauthConfig = getOAuthConfig(connectorName);
29901
+ const tokens = loadTokens2(connectorName);
29902
+ for (const { variable } of getEnvVars(connectorName)) {
29903
+ if (env[variable])
29904
+ continue;
29905
+ if (variable.endsWith("_CLIENT_ID") && oauthConfig.clientId) {
29906
+ env[variable] = oauthConfig.clientId;
29907
+ } else if (variable.endsWith("_CLIENT_SECRET") && oauthConfig.clientSecret) {
29908
+ env[variable] = oauthConfig.clientSecret;
29909
+ } else if (variable.endsWith("_ACCESS_TOKEN") && tokens?.accessToken) {
29910
+ env[variable] = tokens.accessToken;
29911
+ } else if (variable.endsWith("_REFRESH_TOKEN") && tokens?.refreshToken) {
29912
+ env[variable] = tokens.refreshToken;
29913
+ } else if (variable.endsWith("_TOKEN_EXPIRES_AT") && tokens?.expiresAt) {
29914
+ env[variable] = String(tokens.expiresAt);
29915
+ }
29916
+ }
29917
+ }
29581
29918
  return env;
29582
29919
  }
29583
29920
  function getConnectorCliPath(name) {
@@ -29622,7 +29959,7 @@ function parseCommanderHelpOperations(helpText) {
29622
29959
  inCommands = false;
29623
29960
  continue;
29624
29961
  }
29625
- const row = line.match(/^ {2}(\S.*?)(?: {2,}(.+))?$/);
29962
+ const row = line.match(/^ {2}(?! )(\S.*?)(?: {2,}(.+))?$/);
29626
29963
  if (!row)
29627
29964
  continue;
29628
29965
  const usage = row[1].trim();
@@ -29670,7 +30007,7 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
29670
30007
  });
29671
30008
  }
29672
30009
  return new Promise((resolve) => {
29673
- const proc = spawn3("bun", ["run", cliPath, ...args], {
30010
+ const proc = spawn2("bun", ["run", cliPath, ...args], {
29674
30011
  timeout: timeoutMs,
29675
30012
  env: buildEnvWithCredentials(name, process.env),
29676
30013
  stdio: ["pipe", "pipe", "pipe"]
@@ -29750,7 +30087,9 @@ async function getConnectorCommandHelp(name, command) {
29750
30087
  var __dirname5, CONNECTORS_DIR2, ENV_VAR_NAME_OVERRIDES;
29751
30088
  var init_runner = __esm(() => {
29752
30089
  init_builtins();
30090
+ init_connector();
29753
30091
  init_database();
30092
+ init_auth();
29754
30093
  __dirname5 = dirname7(fileURLToPath5(import.meta.url));
29755
30094
  CONNECTORS_DIR2 = resolveConnectorsDir2();
29756
30095
  ENV_VAR_NAME_OVERRIDES = {
@@ -29767,8 +30106,8 @@ var exports_serve = {};
29767
30106
  __export(exports_serve, {
29768
30107
  startServer: () => startServer
29769
30108
  });
29770
- import { existsSync as existsSync17, readdirSync as readdirSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync8, mkdirSync as mkdirSync11 } from "fs";
29771
- import { join as join18, dirname as dirname8, extname, basename } from "path";
30109
+ import { existsSync as existsSync17, readdirSync as readdirSync11, readFileSync as readFileSync8, writeFileSync as writeFileSync7, mkdirSync as mkdirSync11 } from "fs";
30110
+ import { join as join18, dirname as dirname8, extname, basename as basename2 } from "path";
29772
30111
  import { fileURLToPath as fileURLToPath6 } from "url";
29773
30112
  function logActivity(action, connector, detail) {
29774
30113
  activityLog.unshift({ action, connector, timestamp: Date.now(), detail });
@@ -30317,13 +30656,13 @@ ${result.stderr}`;
30317
30656
  if (!isValidConnectorName(name))
30318
30657
  return json({ error: "Invalid connector name" }, 400, port);
30319
30658
  try {
30320
- const profiles = listProfiles2(name);
30659
+ const profiles = listProfiles3(name);
30321
30660
  const configDir = join18(getConnectorsHome(), name.startsWith("connect-") ? name : `connect-${name}`);
30322
30661
  const currentProfileFile = join18(configDir, "current_profile");
30323
30662
  let current = "default";
30324
30663
  if (existsSync17(currentProfileFile)) {
30325
30664
  try {
30326
- current = readFileSync9(currentProfileFile, "utf-8").trim() || "default";
30665
+ current = readFileSync8(currentProfileFile, "utf-8").trim() || "default";
30327
30666
  } catch {}
30328
30667
  }
30329
30668
  return json({ current, profiles }, 200, port);
@@ -30385,9 +30724,9 @@ ${result.stderr}`;
30385
30724
  const profileEntries = readdirSync11(profilesDir, { withFileTypes: true });
30386
30725
  for (const pEntry of profileEntries) {
30387
30726
  if (pEntry.isFile() && pEntry.name.endsWith(".json")) {
30388
- const profileName = basename(pEntry.name, ".json");
30727
+ const profileName = basename2(pEntry.name, ".json");
30389
30728
  try {
30390
- const config = JSON.parse(readFileSync9(join18(profilesDir, pEntry.name), "utf-8"));
30729
+ const config = JSON.parse(readFileSync8(join18(profilesDir, pEntry.name), "utf-8"));
30391
30730
  profiles[profileName] = config;
30392
30731
  } catch {}
30393
30732
  }
@@ -30395,7 +30734,7 @@ ${result.stderr}`;
30395
30734
  const configPath = join18(profilesDir, pEntry.name, "config.json");
30396
30735
  if (existsSync17(configPath)) {
30397
30736
  try {
30398
- const config = JSON.parse(readFileSync9(configPath, "utf-8"));
30737
+ const config = JSON.parse(readFileSync8(configPath, "utf-8"));
30399
30738
  profiles[pEntry.name] = config;
30400
30739
  } catch {}
30401
30740
  }
@@ -30443,7 +30782,7 @@ ${result.stderr}`;
30443
30782
  continue;
30444
30783
  mkdirSync11(profilesDir, { recursive: true });
30445
30784
  const profileFile = join18(profilesDir, `${profileName}.json`);
30446
- writeFileSync8(profileFile, JSON.stringify(config, null, 2));
30785
+ writeFileSync7(profileFile, JSON.stringify(config, null, 2));
30447
30786
  imported++;
30448
30787
  }
30449
30788
  }
@@ -30568,7 +30907,7 @@ var init_serve = __esm(() => {
30568
30907
  // src/cli/index.tsx
30569
30908
  import { render as render2 } from "ink";
30570
30909
 
30571
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/esm.mjs
30910
+ // node_modules/commander/esm.mjs
30572
30911
  var import__ = __toESM(require_commander(), 1);
30573
30912
  var {
30574
30913
  program,
@@ -30592,11 +30931,11 @@ init_registry2();
30592
30931
  import { useState as useState7 } from "react";
30593
30932
  import { Box as Box8, Text as Text10, useApp, useInput as useInput5 } from "ink";
30594
30933
 
30595
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/Indicator.js
30934
+ // node_modules/ink-select-input/build/Indicator.js
30596
30935
  import React from "react";
30597
30936
  import { Box, Text } from "ink";
30598
30937
 
30599
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/is-unicode-supported/index.js
30938
+ // node_modules/is-unicode-supported/index.js
30600
30939
  import process2 from "process";
30601
30940
  function isUnicodeSupported() {
30602
30941
  const { env } = process2;
@@ -30607,7 +30946,7 @@ function isUnicodeSupported() {
30607
30946
  return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
30608
30947
  }
30609
30948
 
30610
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/figures/index.js
30949
+ // node_modules/figures/index.js
30611
30950
  var common = {
30612
30951
  circleQuestionMark: "(?)",
30613
30952
  questionMarkPrefix: "(?)",
@@ -30883,23 +31222,23 @@ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
30883
31222
  var figures_default = figures;
30884
31223
  var replacements = Object.entries(specialMainSymbols);
30885
31224
 
30886
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/Indicator.js
31225
+ // node_modules/ink-select-input/build/Indicator.js
30887
31226
  function Indicator({ isSelected = false }) {
30888
31227
  return React.createElement(Box, { marginRight: 1 }, isSelected ? React.createElement(Text, { color: "blue" }, figures_default.pointer) : React.createElement(Text, null, " "));
30889
31228
  }
30890
31229
  var Indicator_default = Indicator;
30891
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/Item.js
31230
+ // node_modules/ink-select-input/build/Item.js
30892
31231
  import * as React2 from "react";
30893
31232
  import { Text as Text2 } from "ink";
30894
31233
  function Item({ isSelected = false, label }) {
30895
31234
  return React2.createElement(Text2, { color: isSelected ? "blue" : undefined }, label);
30896
31235
  }
30897
31236
  var Item_default = Item;
30898
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/SelectInput.js
31237
+ // node_modules/ink-select-input/build/SelectInput.js
30899
31238
  import { isDeepStrictEqual } from "util";
30900
31239
  import React3, { useState, useEffect, useRef, useCallback } from "react";
30901
31240
 
30902
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/to-rotated/index.js
31241
+ // node_modules/to-rotated/index.js
30903
31242
  function toRotated(array, steps) {
30904
31243
  if (!Array.isArray(array)) {
30905
31244
  throw new TypeError(`Expected an array, got \`${typeof array}\`.`);
@@ -30921,7 +31260,7 @@ function toRotated(array, steps) {
30921
31260
  ];
30922
31261
  }
30923
31262
 
30924
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/SelectInput.js
31263
+ // node_modules/ink-select-input/build/SelectInput.js
30925
31264
  import { Box as Box2, useInput } from "ink";
30926
31265
  function SelectInput({ items = [], isFocused = true, initialIndex = 0, indicatorComponent = Indicator_default, itemComponent = Item_default, limit: customLimit, onSelect, onHighlight }) {
30927
31266
  const hasLimit = typeof customLimit === "number" && items.length > customLimit;
@@ -31334,7 +31673,7 @@ function ConnectorSelect({
31334
31673
  import { useState as useState4, useEffect as useEffect3, useMemo as useMemo2 } from "react";
31335
31674
  import { Box as Box6, Text as Text7, useInput as useInput4 } from "ink";
31336
31675
 
31337
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-text-input/build/index.js
31676
+ // node_modules/ink-text-input/build/index.js
31338
31677
  import React5, { useState as useState3, useEffect as useEffect2 } from "react";
31339
31678
  import { Text as Text6, useInput as useInput3 } from "ink";
31340
31679
  import chalk from "chalk";
@@ -31722,7 +32061,7 @@ function SearchView({
31722
32061
  import { useState as useState6, useEffect as useEffect5 } from "react";
31723
32062
  import { Box as Box7, Text as Text9 } from "ink";
31724
32063
 
31725
- // ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-spinner/build/index.js
32064
+ // node_modules/ink-spinner/build/index.js
31726
32065
  var import_cli_spinners = __toESM(require_cli_spinners(), 1);
31727
32066
  import React7, { useState as useState5, useEffect as useEffect4 } from "react";
31728
32067
  import { Text as Text8 } from "ink";
@@ -32750,7 +33089,7 @@ init_installer();
32750
33089
  init_auth();
32751
33090
  init_database();
32752
33091
  import chalk4 from "chalk";
32753
- import { existsSync as existsSync18, readdirSync as readdirSync12, statSync as statSync7, readFileSync as readFileSync10 } from "fs";
33092
+ import { existsSync as existsSync18, readdirSync as readdirSync12, statSync as statSync7, readFileSync as readFileSync9 } from "fs";
32754
33093
  import { join as join19 } from "path";
32755
33094
  function registerCommands3(program2) {
32756
33095
  program2.command("status").option("--json", "Output as JSON", false).description("Show auth status of all configured connectors (project + global)").action((options) => {
@@ -32765,7 +33104,7 @@ function registerCommands3(program2) {
32765
33104
  let profile = "default";
32766
33105
  if (existsSync18(currentProfileFile)) {
32767
33106
  try {
32768
- profile = readFileSync10(currentProfileFile, "utf-8").trim() || "default";
33107
+ profile = readFileSync9(currentProfileFile, "utf-8").trim() || "default";
32769
33108
  } catch {}
32770
33109
  }
32771
33110
  let expiryLabel = null;
@@ -33022,7 +33361,7 @@ init_registry2();
33022
33361
  init_auth();
33023
33362
  init_database();
33024
33363
  import chalk5 from "chalk";
33025
- import { existsSync as existsSync19, readdirSync as readdirSync13, statSync as statSync8, readFileSync as readFileSync11, writeFileSync as writeFileSync9, mkdirSync as mkdirSync12 } from "fs";
33364
+ import { existsSync as existsSync19, readdirSync as readdirSync13, statSync as statSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync8, mkdirSync as mkdirSync12 } from "fs";
33026
33365
  import { join as join20 } from "path";
33027
33366
  import { homedir as homedir8 } from "os";
33028
33367
  import { createInterface as createInterface2 } from "readline";
@@ -33076,7 +33415,7 @@ function redactSecrets(obj) {
33076
33415
  return obj;
33077
33416
  }
33078
33417
  function getOAuthTokenState(name) {
33079
- const tokens = loadTokens(name);
33418
+ const tokens = loadTokens2(name);
33080
33419
  if (!tokens?.accessToken && !tokens?.refreshToken) {
33081
33420
  return { hasTokens: false, expired: false };
33082
33421
  }
@@ -33219,9 +33558,9 @@ ${meta.displayName} \u2014 Auth Configuration
33219
33558
  try {
33220
33559
  if (!options.browser) {
33221
33560
  console.log(chalk5.dim(`Starting OAuth server on port ${port}...`));
33222
- const { spawn: spawn4 } = await import("child_process");
33561
+ const { spawn: spawn3 } = await import("child_process");
33223
33562
  const scriptPath = process.argv[1];
33224
- const serverProc = spawn4("node", [scriptPath, "serve", "--port", String(port)], {
33563
+ const serverProc = spawn3("node", [scriptPath, "serve", "--port", String(port)], {
33225
33564
  detached: true,
33226
33565
  stdio: "ignore"
33227
33566
  });
@@ -33459,7 +33798,7 @@ Open this URL to authenticate:
33459
33798
  const credentialsPath = join20(entryPath, "credentials.json");
33460
33799
  if (existsSync19(credentialsPath)) {
33461
33800
  try {
33462
- credentials = JSON.parse(readFileSync11(credentialsPath, "utf-8"));
33801
+ credentials = JSON.parse(readFileSync10(credentialsPath, "utf-8"));
33463
33802
  } catch {}
33464
33803
  }
33465
33804
  const profilesDir = join20(entryPath, "profiles");
@@ -33471,7 +33810,7 @@ Open this URL to authenticate:
33471
33810
  const pPath = join20(profilesDir, pEntry);
33472
33811
  if (statSync8(pPath).isFile() && pEntry.endsWith(".json")) {
33473
33812
  try {
33474
- profiles[pEntry.replace(/\.json$/, "")] = JSON.parse(readFileSync11(pPath, "utf-8"));
33813
+ profiles[pEntry.replace(/\.json$/, "")] = JSON.parse(readFileSync10(pPath, "utf-8"));
33475
33814
  } catch {}
33476
33815
  } else if (statSync8(pPath).isDirectory()) {
33477
33816
  const configPath = join20(pPath, "config.json");
@@ -33479,12 +33818,12 @@ Open this URL to authenticate:
33479
33818
  let merged = {};
33480
33819
  if (existsSync19(configPath)) {
33481
33820
  try {
33482
- merged = { ...merged, ...JSON.parse(readFileSync11(configPath, "utf-8")) };
33821
+ merged = { ...merged, ...JSON.parse(readFileSync10(configPath, "utf-8")) };
33483
33822
  } catch {}
33484
33823
  }
33485
33824
  if (existsSync19(tokensPath)) {
33486
33825
  try {
33487
- merged = { ...merged, ...JSON.parse(readFileSync11(tokensPath, "utf-8")) };
33826
+ merged = { ...merged, ...JSON.parse(readFileSync10(tokensPath, "utf-8")) };
33488
33827
  } catch {}
33489
33828
  }
33490
33829
  if (Object.keys(merged).length > 0)
@@ -33505,7 +33844,7 @@ Open this URL to authenticate:
33505
33844
  }
33506
33845
  const exportData = JSON.stringify(exportPayload, null, 2);
33507
33846
  if (options.output) {
33508
- writeFileSync9(options.output, exportData);
33847
+ writeFileSync8(options.output, exportData);
33509
33848
  console.log(chalk5.green(`\u2713 Exported to ${options.output}`));
33510
33849
  } else {
33511
33850
  console.log(exportData);
@@ -33528,7 +33867,7 @@ Open this URL to authenticate:
33528
33867
  process.exit(1);
33529
33868
  return;
33530
33869
  }
33531
- raw = readFileSync11(file, "utf-8");
33870
+ raw = readFileSync10(file, "utf-8");
33532
33871
  }
33533
33872
  let data;
33534
33873
  try {
@@ -33559,7 +33898,7 @@ Open this URL to authenticate:
33559
33898
  const connectorDir = join20(connectDir, `connect-${connectorName}`);
33560
33899
  if (connData.credentials && typeof connData.credentials === "object") {
33561
33900
  mkdirSync12(connectorDir, { recursive: true });
33562
- writeFileSync9(join20(connectorDir, "credentials.json"), JSON.stringify(connData.credentials, null, 2));
33901
+ writeFileSync8(join20(connectorDir, "credentials.json"), JSON.stringify(connData.credentials, null, 2));
33563
33902
  imported++;
33564
33903
  }
33565
33904
  if (!connData.profiles || typeof connData.profiles !== "object")
@@ -33569,7 +33908,7 @@ Open this URL to authenticate:
33569
33908
  if (!config || typeof config !== "object")
33570
33909
  continue;
33571
33910
  mkdirSync12(profilesDir, { recursive: true });
33572
- writeFileSync9(join20(profilesDir, `${profileName}.json`), JSON.stringify(config, null, 2));
33911
+ writeFileSync8(join20(profilesDir, `${profileName}.json`), JSON.stringify(config, null, 2));
33573
33912
  imported++;
33574
33913
  }
33575
33914
  }
@@ -33631,8 +33970,8 @@ Open this URL to authenticate:
33631
33970
  if (!options.dryRun) {
33632
33971
  const parentDir = join20(destPath, "..");
33633
33972
  mkdirSync12(parentDir, { recursive: true });
33634
- const content = readFileSync11(srcPath);
33635
- writeFileSync9(destPath, content);
33973
+ const content = readFileSync10(srcPath);
33974
+ writeFileSync8(destPath, content);
33636
33975
  }
33637
33976
  copiedFiles.push(relFile);
33638
33977
  }
@@ -33698,7 +34037,7 @@ init_installer();
33698
34037
  init_auth();
33699
34038
  init_database();
33700
34039
  import chalk6 from "chalk";
33701
- import { existsSync as existsSync20, readdirSync as readdirSync14, statSync as statSync9, readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
34040
+ import { existsSync as existsSync20, readdirSync as readdirSync14, statSync as statSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync9 } from "fs";
33702
34041
  import { join as join21 } from "path";
33703
34042
 
33704
34043
  // src/lib/test-endpoints.ts
@@ -34086,7 +34425,7 @@ complete -F _connectors connectors`);
34086
34425
  `) + `
34087
34426
  `;
34088
34427
  if (options.output) {
34089
- writeFileSync10(options.output, output);
34428
+ writeFileSync9(options.output, output);
34090
34429
  console.log(chalk6.green(`\u2713 Written to ${options.output} (${vars.length} variables)`));
34091
34430
  } else {
34092
34431
  console.log(output);
@@ -34133,7 +34472,7 @@ Available presets:
34133
34472
  let profile = "default";
34134
34473
  if (existsSync20(currentProfileFile)) {
34135
34474
  try {
34136
- profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
34475
+ profile = readFileSync11(currentProfileFile, "utf-8").trim() || "default";
34137
34476
  } catch {}
34138
34477
  }
34139
34478
  connectorDetails.push({ name, configured: auth.configured, authType: auth.type, profile, source: "project" });
@@ -34162,7 +34501,7 @@ Available presets:
34162
34501
  let profile = "default";
34163
34502
  if (existsSync20(currentProfileFile)) {
34164
34503
  try {
34165
- profile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
34504
+ profile = readFileSync11(currentProfileFile, "utf-8").trim() || "default";
34166
34505
  } catch {}
34167
34506
  }
34168
34507
  connectorDetails.push({ name, configured: true, authType: auth.type, profile, source: "global" });
@@ -34281,13 +34620,13 @@ Testing connector credentials...
34281
34620
  const currentProfileFile = join21(connectorConfigDir, "current_profile");
34282
34621
  if (existsSync20(currentProfileFile)) {
34283
34622
  try {
34284
- currentProfile = readFileSync12(currentProfileFile, "utf-8").trim() || "default";
34623
+ currentProfile = readFileSync11(currentProfileFile, "utf-8").trim() || "default";
34285
34624
  } catch {}
34286
34625
  }
34287
34626
  const tokensFile = join21(connectorConfigDir, "profiles", currentProfile, "tokens.json");
34288
34627
  if (existsSync20(tokensFile)) {
34289
34628
  try {
34290
- const tokens = JSON.parse(readFileSync12(tokensFile, "utf-8"));
34629
+ const tokens = JSON.parse(readFileSync11(tokensFile, "utf-8"));
34291
34630
  const isExpired = tokens.expiresAt && Date.now() >= tokens.expiresAt - 60000;
34292
34631
  if (isExpired && tokens.refreshToken) {
34293
34632
  try {
@@ -34308,7 +34647,7 @@ Testing connector credentials...
34308
34647
  const profileFile = join21(connectorConfigDir, "profiles", `${currentProfile}.json`);
34309
34648
  if (existsSync20(profileFile)) {
34310
34649
  try {
34311
- const config = JSON.parse(readFileSync12(profileFile, "utf-8"));
34650
+ const config = JSON.parse(readFileSync11(profileFile, "utf-8"));
34312
34651
  apiKey = Object.values(config).find((v) => typeof v === "string" && v.length > 0);
34313
34652
  } catch {}
34314
34653
  }
@@ -34317,7 +34656,7 @@ Testing connector credentials...
34317
34656
  const profileDirConfig = join21(connectorConfigDir, "profiles", currentProfile, "config.json");
34318
34657
  if (existsSync20(profileDirConfig)) {
34319
34658
  try {
34320
- const config = JSON.parse(readFileSync12(profileDirConfig, "utf-8"));
34659
+ const config = JSON.parse(readFileSync11(profileDirConfig, "utf-8"));
34321
34660
  apiKey = Object.values(config).find((v) => typeof v === "string" && v.length > 0);
34322
34661
  } catch {}
34323
34662
  }
@@ -34557,12 +34896,12 @@ Setting up ${meta.displayName}...
34557
34896
  ${chalk7.bold("Open this URL to authenticate:")}`);
34558
34897
  console.log(` ${chalk7.cyan(oauthUrl)}
34559
34898
  `);
34560
- const { spawn: spawn4 } = await import("child_process");
34899
+ const { spawn: spawn3 } = await import("child_process");
34561
34900
  const { getConnectorsHome: getConnectorsHome2 } = await Promise.resolve().then(() => (init_database(), exports_database));
34562
34901
  const { existsSync: existsSync8 } = await import("fs");
34563
34902
  const { join: join8 } = await import("path");
34564
34903
  const scriptPath = process.argv[1];
34565
- const serverProc = spawn4("node", [scriptPath, "serve", "--port", String(port)], {
34904
+ const serverProc = spawn3("node", [scriptPath, "serve", "--port", String(port)], {
34566
34905
  detached: true,
34567
34906
  stdio: "ignore"
34568
34907
  });