@hasna/connectors 1.3.30 → 1.3.32
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/LICENSE +1 -1
- package/README.md +9 -0
- package/bin/index.js +461 -1702
- package/bin/mcp.js +583 -1768
- package/bin/serve.js +647 -1875
- package/connectors/{imessage → connect-github}/bin/index.js +892 -390
- package/connectors/connect-github/dist/index.js +520 -0
- package/connectors/{cloudflare → connect-yousign}/bun.lock +3 -3
- package/connectors/connect-yousign/node_modules/@types/bun/LICENSE +21 -0
- package/connectors/connect-yousign/node_modules/@types/bun/README.md +20 -0
- package/connectors/connect-yousign/node_modules/@types/bun/index.d.ts +1 -0
- package/connectors/connect-yousign/node_modules/@types/bun/package.json +53 -0
- package/connectors/connect-yousign/node_modules/@types/node/LICENSE +21 -0
- package/connectors/connect-yousign/node_modules/@types/node/README.md +15 -0
- package/connectors/connect-yousign/node_modules/@types/node/assert/strict.d.ts +105 -0
- package/connectors/connect-yousign/node_modules/@types/node/assert.d.ts +955 -0
- package/connectors/connect-yousign/node_modules/@types/node/async_hooks.d.ts +623 -0
- package/connectors/connect-yousign/node_modules/@types/node/buffer.buffer.d.ts +466 -0
- package/connectors/connect-yousign/node_modules/@types/node/buffer.d.ts +1810 -0
- package/connectors/connect-yousign/node_modules/@types/node/child_process.d.ts +1433 -0
- package/connectors/connect-yousign/node_modules/@types/node/cluster.d.ts +486 -0
- package/connectors/connect-yousign/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/@types/node/console.d.ts +151 -0
- package/connectors/connect-yousign/node_modules/@types/node/constants.d.ts +20 -0
- package/connectors/connect-yousign/node_modules/@types/node/crypto.d.ts +4065 -0
- package/connectors/connect-yousign/node_modules/@types/node/dgram.d.ts +564 -0
- package/connectors/connect-yousign/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
- package/connectors/connect-yousign/node_modules/@types/node/dns/promises.d.ts +503 -0
- package/connectors/connect-yousign/node_modules/@types/node/dns.d.ts +922 -0
- package/connectors/connect-yousign/node_modules/@types/node/domain.d.ts +166 -0
- package/connectors/connect-yousign/node_modules/@types/node/events.d.ts +1047 -0
- package/connectors/connect-yousign/node_modules/@types/node/fs/promises.d.ts +1329 -0
- package/connectors/connect-yousign/node_modules/@types/node/fs.d.ts +4678 -0
- package/connectors/connect-yousign/node_modules/@types/node/globals.d.ts +150 -0
- package/connectors/connect-yousign/node_modules/@types/node/globals.typedarray.d.ts +101 -0
- package/connectors/connect-yousign/node_modules/@types/node/http.d.ts +2188 -0
- package/connectors/connect-yousign/node_modules/@types/node/http2.d.ts +2480 -0
- package/connectors/connect-yousign/node_modules/@types/node/https.d.ts +405 -0
- package/connectors/connect-yousign/node_modules/@types/node/index.d.ts +115 -0
- package/connectors/connect-yousign/node_modules/@types/node/inspector/promises.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/@types/node/inspector.d.ts +269 -0
- package/connectors/connect-yousign/node_modules/@types/node/inspector.generated.d.ts +4401 -0
- package/connectors/connect-yousign/node_modules/@types/node/module.d.ts +757 -0
- package/connectors/connect-yousign/node_modules/@types/node/net.d.ts +933 -0
- package/connectors/connect-yousign/node_modules/@types/node/os.d.ts +507 -0
- package/connectors/connect-yousign/node_modules/@types/node/package.json +155 -0
- package/connectors/connect-yousign/node_modules/@types/node/path/posix.d.ts +8 -0
- package/connectors/connect-yousign/node_modules/@types/node/path/win32.d.ts +8 -0
- package/connectors/connect-yousign/node_modules/@types/node/path.d.ts +187 -0
- package/connectors/connect-yousign/node_modules/@types/node/perf_hooks.d.ts +643 -0
- package/connectors/connect-yousign/node_modules/@types/node/process.d.ts +2175 -0
- package/connectors/connect-yousign/node_modules/@types/node/punycode.d.ts +117 -0
- package/connectors/connect-yousign/node_modules/@types/node/querystring.d.ts +152 -0
- package/connectors/connect-yousign/node_modules/@types/node/quic.d.ts +910 -0
- package/connectors/connect-yousign/node_modules/@types/node/readline/promises.d.ts +161 -0
- package/connectors/connect-yousign/node_modules/@types/node/readline.d.ts +542 -0
- package/connectors/connect-yousign/node_modules/@types/node/repl.d.ts +415 -0
- package/connectors/connect-yousign/node_modules/@types/node/sea.d.ts +162 -0
- package/connectors/connect-yousign/node_modules/@types/node/sqlite.d.ts +1065 -0
- package/connectors/connect-yousign/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/connectors/connect-yousign/node_modules/@types/node/stream/promises.d.ts +211 -0
- package/connectors/connect-yousign/node_modules/@types/node/stream/web.d.ts +296 -0
- package/connectors/connect-yousign/node_modules/@types/node/stream.d.ts +1770 -0
- package/connectors/connect-yousign/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/connectors/connect-yousign/node_modules/@types/node/test/reporters.d.ts +96 -0
- package/connectors/connect-yousign/node_modules/@types/node/test.d.ts +2275 -0
- package/connectors/connect-yousign/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/connectors/connect-yousign/node_modules/@types/node/timers.d.ts +159 -0
- package/connectors/connect-yousign/node_modules/@types/node/tls.d.ts +1203 -0
- package/connectors/connect-yousign/node_modules/@types/node/trace_events.d.ts +197 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +462 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.6/index.d.ts +117 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/connectors/connect-yousign/node_modules/@types/node/ts5.7/index.d.ts +117 -0
- package/connectors/connect-yousign/node_modules/@types/node/tty.d.ts +250 -0
- package/connectors/connect-yousign/node_modules/@types/node/url.d.ts +541 -0
- package/connectors/connect-yousign/node_modules/@types/node/util/types.d.ts +558 -0
- package/connectors/connect-yousign/node_modules/@types/node/util.d.ts +1687 -0
- package/connectors/connect-yousign/node_modules/@types/node/v8.d.ts +988 -0
- package/connectors/connect-yousign/node_modules/@types/node/vm.d.ts +1208 -0
- package/connectors/connect-yousign/node_modules/@types/node/wasi.d.ts +202 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/blob.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/console.d.ts +9 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/events.d.ts +106 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/performance.d.ts +45 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/streams.d.ts +115 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/timers.d.ts +44 -0
- package/connectors/connect-yousign/node_modules/@types/node/web-globals/url.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/@types/node/worker_threads.d.ts +717 -0
- package/connectors/connect-yousign/node_modules/@types/node/zlib.d.ts +682 -0
- package/connectors/connect-yousign/node_modules/bun-types/CLAUDE.md +105 -0
- package/connectors/connect-yousign/node_modules/bun-types/README.md +33 -0
- package/connectors/connect-yousign/node_modules/bun-types/bun.d.ts +8481 -0
- package/connectors/connect-yousign/node_modules/bun-types/bun.ns.d.ts +5 -0
- package/connectors/connect-yousign/node_modules/bun-types/bundle.d.ts +74 -0
- package/connectors/connect-yousign/node_modules/bun-types/deprecated.d.ts +184 -0
- package/connectors/connect-yousign/node_modules/bun-types/devserver.d.ts +187 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/README.md +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/bytecode.mdx +447 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/css.mdx +1024 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/esbuild.mdx +304 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/executables.mdx +1318 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/fullstack.mdx +1086 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/hot-reloading.mdx +229 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/html-static.mdx +498 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/index.mdx +1840 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/loaders.mdx +451 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/macros.mdx +328 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/minifier.mdx +1286 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/plugins.mdx +477 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/bundler/standalone-html.mdx +314 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/feedback.mdx +75 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-array.mdx +29 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-blob.mdx +26 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-buffer.mdx +27 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-string.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/arraybuffer-to-typedarray.mdx +41 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-arraybuffer.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-dataview.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-stream.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-string.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/blob-to-typedarray.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-arraybuffer.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-blob.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-readablestream.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-string.mdx +27 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/buffer-to-typedarray.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/dataview-to-string.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-arraybuffer.mdx +27 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-blob.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-buffer.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-dataview.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-readablestream.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/binary/typedarray-to-string.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/aws-lambda.mdx +204 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/digital-ocean.mdx +161 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/google-cloud-run.mdx +194 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/railway.mdx +145 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/render.mdx +82 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/deployment/vercel.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/astro.mdx +82 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/discordjs.mdx +80 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/docker.mdx +151 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/drizzle.mdx +195 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/elysia.mdx +31 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/express.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/gel.mdx +261 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/hono.mdx +47 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/mongoose.mdx +92 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/neon-drizzle.mdx +234 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/neon-serverless-postgres.mdx +60 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/nextjs.mdx +103 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/nuxt.mdx +96 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/pm2.mdx +55 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/prisma-postgres.mdx +169 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/prisma.mdx +164 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/qwik.mdx +114 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/react.mdx +52 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/remix.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/sentry.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/solidstart.mdx +62 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/ssr-react.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/stric.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/sveltekit.mdx +138 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/systemd.mdx +114 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/tanstack-start.mdx +791 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/upstash.mdx +87 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/ecosystem/vite.mdx +77 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/html-rewriter/extract-links.mdx +71 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/html-rewriter/extract-social-meta.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/cluster.mdx +69 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/fetch-unix.mdx +35 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/fetch.mdx +26 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/file-uploads.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/hot.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/proxy.mdx +50 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/server.mdx +48 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/simple.mdx +20 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/stream-file.mdx +50 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/stream-iterator.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/stream-node-streams-in-bun.mdx +22 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/http/tls.mdx +32 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/index.mdx +10 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-dev.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-git.mdx +40 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-optional.mdx +27 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-peer.mdx +45 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add-tarball.mdx +35 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/add.mdx +44 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/azure-artifacts.mdx +76 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/cicd.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/custom-registry.mdx +32 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/from-npm-install-to-bun-install.mdx +230 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/git-diff-bun-lockfile.mdx +48 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/jfrog-artifactory.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/npm-alias.mdx +25 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/registry-scope.mdx +40 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/trusted.mdx +52 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/workspaces.mdx +70 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/install/yarnlock.mdx +51 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/argv.mdx +66 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/ctrl-c.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/ipc.mdx +69 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/nanoseconds.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/os-signals.mdx +31 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/spawn-stderr.mdx +34 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/spawn-stdout.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/spawn.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/process/stdin.mdx +62 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/arraybuffer.mdx +30 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/buffer.mdx +21 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/exists.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/json.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/mime.mdx +22 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/stream.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/string.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/uint8array.mdx +23 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/read-file/watch.mdx +66 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/build-time-constants.mdx +295 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/cicd.mdx +45 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/codesign-macos-executable.mdx +61 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/define-constant.mdx +149 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/delete-directory.mdx +39 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/delete-file.mdx +21 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/heap-snapshot.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-html.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-json.mdx +46 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-json5.mdx +74 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-toml.mdx +32 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/import-yaml.mdx +104 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/read-env.mdx +37 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/set-env.mdx +51 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/shell.mdx +42 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/timezone.mdx +38 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/tsconfig-paths.mdx +31 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/typescript.mdx +51 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/vscode-debugger.mdx +47 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/runtime/web-debugger.mdx +103 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-arraybuffer.mdx +13 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-blob.mdx +13 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-json.mdx +14 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-string.mdx +14 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/node-readable-to-uint8array.mdx +13 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-array.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-arraybuffer.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-blob.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-buffer.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-json.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-string.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/streams/to-typedarray.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/bail.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/concurrent-test-glob.mdx +146 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/coverage-threshold.mdx +67 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/coverage.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/happy-dom.mdx +73 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/migrate-from-jest.mdx +125 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/mock-clock.mdx +50 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/mock-functions.mdx +70 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/rerun-each.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/run-tests.mdx +116 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/skip-tests.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/snapshot.mdx +102 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/spy-on.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/svelte-test.mdx +113 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/testing-library.mdx +93 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/timeout.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/todo-tests.mdx +74 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/update-snapshots.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/test/watch-mode.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/base64.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/deep-equals.mdx +41 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/deflate.mdx +20 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/detect-bun.mdx +28 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/entrypoint.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/escape-html.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/file-url-to-path.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/gzip.mdx +20 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/hash-a-password.mdx +56 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/import-meta-dir.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/import-meta-file.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/import-meta-path.mdx +15 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/javascript-uuid.mdx +25 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/main.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/path-to-file-url.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/sleep.mdx +24 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/upgrade.mdx +93 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/version.mdx +23 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/util/which-path-to-executable-bin.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/websocket/compression.mdx +33 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/websocket/context.mdx +79 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/websocket/pubsub.mdx +43 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/websocket/simple.mdx +38 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/append.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/basic.mdx +46 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/blob.mdx +30 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/cat.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/file-cp.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/filesink.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/response.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/stdout.mdx +23 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/stream.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/guides/write-file/unlink.mdx +18 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/index.mdx +133 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/installation.mdx +372 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/bunx.mdx +91 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/catalogs.mdx +292 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/add.mdx +179 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/audit.mdx +60 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/info.mdx +70 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/install.mdx +591 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/link.mdx +61 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/outdated.mdx +197 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/patch.mdx +69 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/pm.mdx +323 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/publish.mdx +131 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/remove.mdx +16 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/update.mdx +140 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/cli/why.mdx +84 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/filter.mdx +127 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/global-cache.mdx +72 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/isolated-installs.mdx +220 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/lifecycle.mdx +64 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/lockfile.mdx +64 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/npmrc.mdx +245 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/overrides.mdx +83 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/scopes-registries.mdx +35 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/security-scanner-api.mdx +95 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/pm/workspaces.mdx +115 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/benchmarking.mdx +296 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/bindgen.mdx +223 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/building-windows.mdx +143 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/contributing.mdx +366 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/feedback.mdx +20 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/license.mdx +78 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/project/roadmap.mdx +8 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/quickstart.mdx +251 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/archive.mdx +452 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/auto-install.mdx +97 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/binary-data.mdx +846 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/bun-apis.mdx +59 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/bunfig.mdx +754 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/c-compiler.mdx +204 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/child-process.mdx +659 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/color.mdx +267 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/console.mdx +67 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/cookies.mdx +454 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/debugger.mdx +335 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/environment-variables.mdx +231 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/ffi.mdx +567 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/file-io.mdx +306 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/file-system-router.mdx +118 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/file-types.mdx +482 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/glob.mdx +181 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/globals.mdx +72 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/hashing.mdx +315 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/html-rewriter.mdx +333 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/cookies.mdx +79 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/error-handling.mdx +40 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/metrics.mdx +36 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/routing.mdx +289 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/server.mdx +645 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/tls.mdx +101 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/http/websockets.mdx +414 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/index.mdx +223 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/json5.mdx +271 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/jsonl.mdx +188 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/jsx.mdx +115 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/markdown.mdx +344 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/module-resolution.mdx +374 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/networking/dns.mdx +111 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/networking/fetch.mdx +484 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/networking/tcp.mdx +239 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/networking/udp.mdx +180 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/node-api.mdx +19 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/nodejs-compat.mdx +468 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/plugins.mdx +419 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/redis.mdx +583 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/repl.mdx +176 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/s3.mdx +881 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/secrets.mdx +340 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/semver.mdx +57 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/shell.mdx +637 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/sql.mdx +1404 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/sqlite.mdx +721 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/streams.mdx +232 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/templating/create.mdx +269 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/templating/init.mdx +58 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/transpiler.mdx +288 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/typescript.mdx +58 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/utils.mdx +1010 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/watch-mode.mdx +161 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/web-apis.mdx +29 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/workers.mdx +314 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/runtime/yaml.mdx +469 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/add.mdx +166 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/build.mdx +197 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/bunx.mdx +49 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/feedback.mdx +17 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/init.mdx +84 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/install.mdx +173 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/link.mdx +163 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/outdated.mdx +140 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/patch.mdx +171 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/publish.mdx +198 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/remove.mdx +146 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/run.mdx +305 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/test.mdx +105 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/snippets/cli/update.mdx +144 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/code-coverage.mdx +409 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/configuration.mdx +520 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/dates-times.mdx +129 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/discovery.mdx +90 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/dom.mdx +226 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/index.mdx +409 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/lifecycle.mdx +366 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/mocks.mdx +637 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/reporters.mdx +126 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/runtime-behavior.mdx +342 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/snapshots.mdx +434 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/test/writing-tests.mdx +672 -0
- package/connectors/connect-yousign/node_modules/bun-types/docs/typescript.mdx +54 -0
- package/connectors/connect-yousign/node_modules/bun-types/extensions.d.ts +40 -0
- package/connectors/connect-yousign/node_modules/bun-types/fetch.d.ts +79 -0
- package/connectors/connect-yousign/node_modules/bun-types/ffi.d.ts +1154 -0
- package/connectors/connect-yousign/node_modules/bun-types/globals.d.ts +2067 -0
- package/connectors/connect-yousign/node_modules/bun-types/html-rewriter.d.ts +186 -0
- package/connectors/connect-yousign/node_modules/bun-types/index.d.ts +32 -0
- package/connectors/connect-yousign/node_modules/bun-types/jsc.d.ts +233 -0
- package/connectors/connect-yousign/node_modules/bun-types/jsx.d.ts +11 -0
- package/connectors/connect-yousign/node_modules/bun-types/overrides.d.ts +376 -0
- package/connectors/connect-yousign/node_modules/bun-types/package.json +37 -0
- package/connectors/connect-yousign/node_modules/bun-types/redis.d.ts +3352 -0
- package/connectors/connect-yousign/node_modules/bun-types/s3.d.ts +1335 -0
- package/connectors/connect-yousign/node_modules/bun-types/security.d.ts +101 -0
- package/connectors/connect-yousign/node_modules/bun-types/serve.d.ts +1296 -0
- package/connectors/connect-yousign/node_modules/bun-types/shell.d.ts +380 -0
- package/connectors/connect-yousign/node_modules/bun-types/sql.d.ts +887 -0
- package/connectors/connect-yousign/node_modules/bun-types/sqlite.d.ts +1322 -0
- package/connectors/connect-yousign/node_modules/bun-types/test-globals.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/bun-types/test.d.ts +2392 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/branding.d.ts +283 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/index.d.ts +1207 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/messages.d.ts +395 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/overloads.d.ts +669 -0
- package/connectors/connect-yousign/node_modules/bun-types/vendor/expect-type/utils.d.ts +431 -0
- package/connectors/connect-yousign/node_modules/bun-types/wasm.d.ts +193 -0
- package/connectors/connect-yousign/node_modules/chalk/license +9 -0
- package/connectors/connect-yousign/node_modules/chalk/package.json +83 -0
- package/connectors/connect-yousign/node_modules/chalk/readme.md +297 -0
- package/connectors/connect-yousign/node_modules/chalk/source/index.d.ts +325 -0
- package/connectors/connect-yousign/node_modules/chalk/source/index.js +225 -0
- package/connectors/connect-yousign/node_modules/chalk/source/utilities.js +33 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/connectors/connect-yousign/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/connectors/connect-yousign/node_modules/commander/LICENSE +22 -0
- package/connectors/connect-yousign/node_modules/commander/Readme.md +1157 -0
- package/connectors/connect-yousign/node_modules/commander/esm.mjs +16 -0
- package/connectors/connect-yousign/node_modules/commander/index.js +24 -0
- package/connectors/connect-yousign/node_modules/commander/lib/argument.js +149 -0
- package/connectors/connect-yousign/node_modules/commander/lib/command.js +2509 -0
- package/connectors/connect-yousign/node_modules/commander/lib/error.js +39 -0
- package/connectors/connect-yousign/node_modules/commander/lib/help.js +520 -0
- package/connectors/connect-yousign/node_modules/commander/lib/option.js +330 -0
- package/connectors/connect-yousign/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/connectors/connect-yousign/node_modules/commander/package-support.json +16 -0
- package/connectors/connect-yousign/node_modules/commander/package.json +84 -0
- package/connectors/connect-yousign/node_modules/commander/typings/esm.d.mts +3 -0
- package/connectors/connect-yousign/node_modules/commander/typings/index.d.ts +969 -0
- package/connectors/connect-yousign/node_modules/typescript/LICENSE.txt +55 -0
- package/connectors/connect-yousign/node_modules/typescript/README.md +50 -0
- package/connectors/connect-yousign/node_modules/typescript/SECURITY.md +41 -0
- package/connectors/connect-yousign/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
- package/connectors/connect-yousign/node_modules/typescript/bin/tsc +2 -0
- package/connectors/connect-yousign/node_modules/typescript/bin/tsserver +2 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/_tsc.js +133818 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/_tsserver.js +659 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/_typingsInstaller.js +222 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.es6.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tsc.js +8 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tsserver.js +8 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/tsserverlibrary.js +21 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/typesMap.json +497 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/typescript.d.ts +11437 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/typescript.js +200276 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/typingsInstaller.js +8 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/watchGuard.js +53 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
- package/connectors/connect-yousign/node_modules/typescript/package.json +120 -0
- package/connectors/connect-yousign/node_modules/undici-types/LICENSE +21 -0
- package/connectors/connect-yousign/node_modules/undici-types/README.md +6 -0
- package/connectors/connect-yousign/node_modules/undici-types/agent.d.ts +32 -0
- package/connectors/connect-yousign/node_modules/undici-types/api.d.ts +43 -0
- package/connectors/connect-yousign/node_modules/undici-types/balanced-pool.d.ts +30 -0
- package/connectors/connect-yousign/node_modules/undici-types/cache-interceptor.d.ts +173 -0
- package/connectors/connect-yousign/node_modules/undici-types/cache.d.ts +36 -0
- package/connectors/connect-yousign/node_modules/undici-types/client-stats.d.ts +15 -0
- package/connectors/connect-yousign/node_modules/undici-types/client.d.ts +108 -0
- package/connectors/connect-yousign/node_modules/undici-types/connector.d.ts +34 -0
- package/connectors/connect-yousign/node_modules/undici-types/content-type.d.ts +21 -0
- package/connectors/connect-yousign/node_modules/undici-types/cookies.d.ts +30 -0
- package/connectors/connect-yousign/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
- package/connectors/connect-yousign/node_modules/undici-types/dispatcher.d.ts +276 -0
- package/connectors/connect-yousign/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
- package/connectors/connect-yousign/node_modules/undici-types/errors.d.ts +161 -0
- package/connectors/connect-yousign/node_modules/undici-types/eventsource.d.ts +66 -0
- package/connectors/connect-yousign/node_modules/undici-types/fetch.d.ts +211 -0
- package/connectors/connect-yousign/node_modules/undici-types/formdata.d.ts +108 -0
- package/connectors/connect-yousign/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/connectors/connect-yousign/node_modules/undici-types/global-origin.d.ts +7 -0
- package/connectors/connect-yousign/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/connectors/connect-yousign/node_modules/undici-types/handlers.d.ts +15 -0
- package/connectors/connect-yousign/node_modules/undici-types/header.d.ts +160 -0
- package/connectors/connect-yousign/node_modules/undici-types/index.d.ts +88 -0
- package/connectors/connect-yousign/node_modules/undici-types/interceptors.d.ts +73 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-agent.d.ts +68 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-client.d.ts +27 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-interceptor.d.ts +94 -0
- package/connectors/connect-yousign/node_modules/undici-types/mock-pool.d.ts +27 -0
- package/connectors/connect-yousign/node_modules/undici-types/package.json +55 -0
- package/connectors/connect-yousign/node_modules/undici-types/patch.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/connectors/connect-yousign/node_modules/undici-types/pool.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/undici-types/proxy-agent.d.ts +29 -0
- package/connectors/connect-yousign/node_modules/undici-types/readable.d.ts +68 -0
- package/connectors/connect-yousign/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/connectors/connect-yousign/node_modules/undici-types/retry-handler.d.ts +125 -0
- package/connectors/connect-yousign/node_modules/undici-types/round-robin-pool.d.ts +41 -0
- package/connectors/connect-yousign/node_modules/undici-types/snapshot-agent.d.ts +109 -0
- package/connectors/connect-yousign/node_modules/undici-types/util.d.ts +18 -0
- package/connectors/connect-yousign/node_modules/undici-types/utility.d.ts +7 -0
- package/connectors/connect-yousign/node_modules/undici-types/webidl.d.ts +341 -0
- package/connectors/connect-yousign/node_modules/undici-types/websocket.d.ts +186 -0
- package/dashboard/dist/assets/index-CSlS3oNV.css +1 -0
- package/dashboard/dist/assets/index-NCasN7x4.js +284 -0
- package/dashboard/dist/index.html +2 -2
- package/dist/cli/commands/auth.d.ts +0 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +167 -1399
- package/dist/lib/lock.d.ts +1 -1
- package/dist/lib/runner.d.ts +0 -31
- package/dist/lib/workflow-runner.d.ts +0 -7
- package/dist/server/auth.d.ts +3 -4
- package/package.json +1 -1
- package/connectors/gmail/bin/index.js +0 -7027
- package/connectors/googledrive/bin/index.js +0 -5958
- package/connectors/imessage/bin/.gitkeep +0 -2
- package/connectors/imessage/bun.lock +0 -32
- package/dashboard/dist/assets/index-ClBXkNbL.css +0 -1
- package/dashboard/dist/assets/index-DvfmyAO4.js +0 -284
- package/dist/core/builtins.test.d.ts +0 -1
- package/dist/core/connectors/gmail.d.ts +0 -5
- package/dist/core/connectors/googledrive.d.ts +0 -6
- package/dist/core/connectors/internal-operations.test.d.ts +0 -1
- package/dist/core/connectors/internal-runtime.test.d.ts +0 -1
- package/dist/core/errors.test.d.ts +0 -1
- package/dist/lib/connector-resolver.d.ts +0 -37
- package/dist/lib/connector-resolver.test.d.ts +0 -1
- package/dist/lib/manifest.d.ts +0 -50
- package/dist/lib/manifest.test.d.ts +0 -1
- package/dist/lib/runner-auth.test.d.ts +0 -1
- package/dist/lib/test-endpoints.test.d.ts +0 -1
- package/dist/server/auth-exchange.test.d.ts +0 -1
- package/dist/server/auth-refresh.test.d.ts +0 -1
- /package/dist/{cli/auth-no-browser.test.d.ts → server/server.test.d.ts} +0 -0
package/bin/serve.js
CHANGED
|
@@ -10009,7 +10009,7 @@ var init_promotions = __esm(() => {
|
|
|
10009
10009
|
});
|
|
10010
10010
|
|
|
10011
10011
|
// src/server/serve.ts
|
|
10012
|
-
import { existsSync as
|
|
10012
|
+
import { existsSync as existsSync15, readdirSync as readdirSync9, readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync10 } from "fs";
|
|
10013
10013
|
|
|
10014
10014
|
// src/db/agents.ts
|
|
10015
10015
|
init_database();
|
|
@@ -10188,8 +10188,7 @@ init_scheduler();
|
|
|
10188
10188
|
|
|
10189
10189
|
// src/lib/workflow-runner.ts
|
|
10190
10190
|
init_strip();
|
|
10191
|
-
import { spawn as
|
|
10192
|
-
var spawnImpl = nodeSpawn;
|
|
10191
|
+
import { spawn as spawn2 } from "child_process";
|
|
10193
10192
|
async function runStep(step, previousOutput) {
|
|
10194
10193
|
return new Promise((resolve) => {
|
|
10195
10194
|
const args = [...step.args ?? []];
|
|
@@ -10197,7 +10196,7 @@ async function runStep(step, previousOutput) {
|
|
|
10197
10196
|
args.push("--input", previousOutput.trim().slice(0, 4096));
|
|
10198
10197
|
}
|
|
10199
10198
|
const cmdArgs = ["run", step.connector, step.command, ...args, "--format", "json"];
|
|
10200
|
-
const proc =
|
|
10199
|
+
const proc = spawn2("connectors", cmdArgs, { shell: false });
|
|
10201
10200
|
let output = "";
|
|
10202
10201
|
proc.stdout.on("data", (d) => {
|
|
10203
10202
|
output += d.toString();
|
|
@@ -10240,12 +10239,12 @@ async function runWorkflow(workflow) {
|
|
|
10240
10239
|
|
|
10241
10240
|
// src/server/serve.ts
|
|
10242
10241
|
init_database();
|
|
10243
|
-
import { join as
|
|
10242
|
+
import { join as join16, dirname as dirname8, extname, basename } from "path";
|
|
10244
10243
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
10245
10244
|
|
|
10246
10245
|
// src/lib/registry.ts
|
|
10247
|
-
import { existsSync as
|
|
10248
|
-
import { join as
|
|
10246
|
+
import { existsSync as existsSync10, readFileSync as readFileSync4 } from "fs";
|
|
10247
|
+
import { join as join11, dirname as dirname5 } from "path";
|
|
10249
10248
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
10250
10249
|
|
|
10251
10250
|
// src/core/errors.ts
|
|
@@ -10258,20 +10257,9 @@ class ConnectorDefinitionError extends Error {
|
|
|
10258
10257
|
}
|
|
10259
10258
|
}
|
|
10260
10259
|
|
|
10261
|
-
class ConnectorOperationNotFoundError extends Error {
|
|
10262
|
-
connectorName;
|
|
10263
|
-
operationName;
|
|
10264
|
-
constructor(connectorName, operationName) {
|
|
10265
|
-
super(`Operation '${operationName}' not found on connector '${connectorName}'`);
|
|
10266
|
-
this.name = "ConnectorOperationNotFoundError";
|
|
10267
|
-
this.connectorName = connectorName;
|
|
10268
|
-
this.operationName = operationName;
|
|
10269
|
-
}
|
|
10270
|
-
}
|
|
10271
|
-
|
|
10272
10260
|
// src/core/connector.ts
|
|
10273
10261
|
var CONNECTOR_NAME_RE = /^[a-z0-9-]+$/;
|
|
10274
|
-
var OPERATION_NAME_RE = /^[
|
|
10262
|
+
var OPERATION_NAME_RE = /^[a-z0-9:_-]+$/;
|
|
10275
10263
|
function defineConnector(definition) {
|
|
10276
10264
|
const { meta, auth, operations } = definition;
|
|
10277
10265
|
if (!CONNECTOR_NAME_RE.test(meta.name)) {
|
|
@@ -10310,29 +10298,6 @@ function defineConnector(definition) {
|
|
|
10310
10298
|
operations: normalizedOperations
|
|
10311
10299
|
};
|
|
10312
10300
|
}
|
|
10313
|
-
function listConnectorOperations(connector) {
|
|
10314
|
-
return Object.values(connector.operations).sort((a, b) => a.name.localeCompare(b.name));
|
|
10315
|
-
}
|
|
10316
|
-
function getConnectorOperation(connector, name) {
|
|
10317
|
-
return listConnectorOperations(connector).find((operation) => operation.name === name);
|
|
10318
|
-
}
|
|
10319
|
-
async function executeConnectorOperation(connector, args) {
|
|
10320
|
-
const operation = getConnectorOperation(connector, args.operation);
|
|
10321
|
-
if (!operation) {
|
|
10322
|
-
throw new ConnectorOperationNotFoundError(connector.meta.name, args.operation);
|
|
10323
|
-
}
|
|
10324
|
-
const context = connector.createContext ? await connector.createContext({
|
|
10325
|
-
credentials: args.credentials,
|
|
10326
|
-
profile: args.profile
|
|
10327
|
-
}) : undefined;
|
|
10328
|
-
const parsedInput = operation.inputSchema ? operation.inputSchema.parse(args.input ?? {}) : args.input ?? {};
|
|
10329
|
-
return operation.execute({
|
|
10330
|
-
connector,
|
|
10331
|
-
context,
|
|
10332
|
-
profile: args.profile,
|
|
10333
|
-
credentials: args.credentials
|
|
10334
|
-
}, parsedInput);
|
|
10335
|
-
}
|
|
10336
10301
|
|
|
10337
10302
|
// src/core/registry.ts
|
|
10338
10303
|
function createConnectorDefinitionRegistry(definitions) {
|
|
@@ -14339,10 +14304,10 @@ var NEVER2 = INVALID2;
|
|
|
14339
14304
|
var __dirname2 = dirname3(fileURLToPath(import.meta.url));
|
|
14340
14305
|
function resolveGithubConnectorDir() {
|
|
14341
14306
|
const candidates = [
|
|
14342
|
-
join8(__dirname2, "..", "..", "..", "connectors", "github"),
|
|
14343
|
-
join8(__dirname2, "..", "..", "connectors", "github"),
|
|
14344
|
-
join8(__dirname2, "..", "connectors", "github"),
|
|
14345
|
-
join8(process.cwd(), "connectors", "github")
|
|
14307
|
+
join8(__dirname2, "..", "..", "..", "connectors", "connect-github"),
|
|
14308
|
+
join8(__dirname2, "..", "..", "connectors", "connect-github"),
|
|
14309
|
+
join8(__dirname2, "..", "connectors", "connect-github"),
|
|
14310
|
+
join8(process.cwd(), "connectors", "connect-github")
|
|
14346
14311
|
];
|
|
14347
14312
|
for (const candidate of candidates) {
|
|
14348
14313
|
if (existsSync7(candidate)) {
|
|
@@ -15192,805 +15157,10 @@ var githubConnector = defineConnector({
|
|
|
15192
15157
|
}
|
|
15193
15158
|
}
|
|
15194
15159
|
});
|
|
15195
|
-
|
|
15196
|
-
// src/core/connectors/gmail.ts
|
|
15197
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync3, readdirSync as readdirSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
15198
|
-
import { homedir as homedir8 } from "os";
|
|
15199
|
-
import { basename, join as join9 } from "path";
|
|
15200
|
-
var GMAIL_API_BASE = "https://gmail.googleapis.com/gmail/v1";
|
|
15201
|
-
var TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
15202
|
-
var REFRESH_BUFFER_MS = 5 * 60 * 1000;
|
|
15203
|
-
var MAX_GMAIL_RETRIES = 5;
|
|
15204
|
-
var listMessagesSchema = exports_external2.object({
|
|
15205
|
-
max: exports_external2.coerce.number().int().positive().max(500).optional(),
|
|
15206
|
-
maxResults: exports_external2.coerce.number().int().positive().max(500).optional(),
|
|
15207
|
-
pageToken: exports_external2.string().optional(),
|
|
15208
|
-
query: exports_external2.string().optional(),
|
|
15209
|
-
q: exports_external2.string().optional(),
|
|
15210
|
-
label: exports_external2.string().optional(),
|
|
15211
|
-
labelIds: exports_external2.union([exports_external2.string(), exports_external2.array(exports_external2.string())]).optional(),
|
|
15212
|
-
includeSpamTrash: exports_external2.boolean().optional()
|
|
15213
|
-
});
|
|
15214
|
-
var messageIdSchema = exports_external2.object({
|
|
15215
|
-
args: exports_external2.array(exports_external2.union([exports_external2.string(), exports_external2.number(), exports_external2.boolean()])).optional(),
|
|
15216
|
-
messageId: exports_external2.string().optional()
|
|
15217
|
-
});
|
|
15218
|
-
var readMessageSchema = messageIdSchema.extend({
|
|
15219
|
-
body: exports_external2.boolean().optional(),
|
|
15220
|
-
html: exports_external2.boolean().optional(),
|
|
15221
|
-
format: exports_external2.enum(["full", "metadata", "minimal", "raw"]).optional()
|
|
15222
|
-
});
|
|
15223
|
-
var attachmentListSchema = messageIdSchema;
|
|
15224
|
-
var attachmentDownloadSchema = messageIdSchema.extend({
|
|
15225
|
-
attachmentId: exports_external2.string().optional(),
|
|
15226
|
-
filename: exports_external2.string().optional(),
|
|
15227
|
-
mimeType: exports_external2.string().optional(),
|
|
15228
|
-
dir: exports_external2.string().optional(),
|
|
15229
|
-
outputDir: exports_external2.string().optional()
|
|
15230
|
-
});
|
|
15231
|
-
var historyListSchema = exports_external2.object({
|
|
15232
|
-
startHistoryId: exports_external2.string(),
|
|
15233
|
-
historyTypes: exports_external2.union([exports_external2.string(), exports_external2.array(exports_external2.string())]).optional(),
|
|
15234
|
-
labelId: exports_external2.string().optional(),
|
|
15235
|
-
maxResults: exports_external2.coerce.number().int().positive().max(500).optional(),
|
|
15236
|
-
pageToken: exports_external2.string().optional()
|
|
15237
|
-
});
|
|
15238
|
-
var replySchema = messageIdSchema.extend({
|
|
15239
|
-
body: exports_external2.string(),
|
|
15240
|
-
html: exports_external2.boolean().optional(),
|
|
15241
|
-
isHtml: exports_external2.boolean().optional(),
|
|
15242
|
-
cc: exports_external2.union([exports_external2.string(), exports_external2.array(exports_external2.string())]).optional(),
|
|
15243
|
-
bcc: exports_external2.union([exports_external2.string(), exports_external2.array(exports_external2.string())]).optional()
|
|
15244
|
-
});
|
|
15245
|
-
var gmailConnector = defineConnector({
|
|
15246
|
-
meta: {
|
|
15247
|
-
name: "gmail",
|
|
15248
|
-
displayName: "Gmail",
|
|
15249
|
-
description: "Profile-aware Gmail mailbox operations for sync, labels, attachments, history, and replies.",
|
|
15250
|
-
category: "communication",
|
|
15251
|
-
tags: ["google", "gmail", "email", "mailbox"]
|
|
15252
|
-
},
|
|
15253
|
-
auth: {
|
|
15254
|
-
type: "oauth2",
|
|
15255
|
-
supportsProfiles: true,
|
|
15256
|
-
fields: [
|
|
15257
|
-
{ key: "clientId", env: "GMAIL_CLIENT_ID", label: "OAuth client ID" },
|
|
15258
|
-
{ key: "clientSecret", env: "GMAIL_CLIENT_SECRET", label: "OAuth client secret", secret: true }
|
|
15259
|
-
]
|
|
15260
|
-
},
|
|
15261
|
-
createContext: ({ profile }) => ({ profile: profile || "default" }),
|
|
15262
|
-
operations: {
|
|
15263
|
-
"profiles.list": {
|
|
15264
|
-
summary: "List configured Gmail profiles.",
|
|
15265
|
-
execute: () => ({ profiles: listProfiles() })
|
|
15266
|
-
},
|
|
15267
|
-
"profile.get": {
|
|
15268
|
-
summary: "Get the authenticated Gmail profile.",
|
|
15269
|
-
execute: async ({ context }) => requestJson(context.profile, "/users/me/profile", {})
|
|
15270
|
-
},
|
|
15271
|
-
"messages.list": {
|
|
15272
|
-
summary: "List Gmail messages.",
|
|
15273
|
-
inputSchema: listMessagesSchema,
|
|
15274
|
-
execute: async ({ context }, input) => {
|
|
15275
|
-
const labelIds = normalizeStringArray(input.labelIds ?? input.label);
|
|
15276
|
-
return requestJson(context.profile, "/users/me/messages", {
|
|
15277
|
-
maxResults: input.maxResults ?? input.max ?? 50,
|
|
15278
|
-
pageToken: input.pageToken,
|
|
15279
|
-
q: input.q ?? input.query,
|
|
15280
|
-
labelIds: labelIds.length > 0 ? labelIds.join(",") : undefined,
|
|
15281
|
-
includeSpamTrash: input.includeSpamTrash
|
|
15282
|
-
});
|
|
15283
|
-
}
|
|
15284
|
-
},
|
|
15285
|
-
"messages.read": {
|
|
15286
|
-
summary: "Read a Gmail message with optional extracted body.",
|
|
15287
|
-
inputSchema: readMessageSchema,
|
|
15288
|
-
execute: async ({ context }, input) => {
|
|
15289
|
-
const messageId = getMessageId(input);
|
|
15290
|
-
const message = await requestJson(context.profile, `/users/me/messages/${encodeURIComponent(messageId)}`, { format: input.format ?? "full" });
|
|
15291
|
-
const headers = headersToObject(message.payload?.headers ?? []);
|
|
15292
|
-
return {
|
|
15293
|
-
...message,
|
|
15294
|
-
from: headers.From ?? headers.from ?? "",
|
|
15295
|
-
to: headers.To ?? headers.to ?? "",
|
|
15296
|
-
cc: headers.Cc ?? headers.cc ?? "",
|
|
15297
|
-
subject: headers.Subject ?? headers.subject ?? "",
|
|
15298
|
-
date: headers.Date ?? headers.date ?? "",
|
|
15299
|
-
body: input.body ? extractBody(message, Boolean(input.html)) : undefined,
|
|
15300
|
-
size: message.sizeEstimate
|
|
15301
|
-
};
|
|
15302
|
-
}
|
|
15303
|
-
},
|
|
15304
|
-
"messages.getRaw": {
|
|
15305
|
-
summary: "Read raw base64url Gmail message content.",
|
|
15306
|
-
inputSchema: messageIdSchema,
|
|
15307
|
-
execute: async ({ context }, input) => {
|
|
15308
|
-
const messageId = getMessageId(input);
|
|
15309
|
-
return requestJson(context.profile, `/users/me/messages/${encodeURIComponent(messageId)}`, { format: "raw" });
|
|
15310
|
-
}
|
|
15311
|
-
},
|
|
15312
|
-
"messages.mark-read": {
|
|
15313
|
-
summary: "Mark a message as read.",
|
|
15314
|
-
inputSchema: messageIdSchema,
|
|
15315
|
-
execute: async ({ context }, input) => modifyMessage(context.profile, getMessageId(input), undefined, ["UNREAD"])
|
|
15316
|
-
},
|
|
15317
|
-
"messages.mark-unread": {
|
|
15318
|
-
summary: "Mark a message as unread.",
|
|
15319
|
-
inputSchema: messageIdSchema,
|
|
15320
|
-
execute: async ({ context }, input) => modifyMessage(context.profile, getMessageId(input), ["UNREAD"], undefined)
|
|
15321
|
-
},
|
|
15322
|
-
"messages.archive": {
|
|
15323
|
-
summary: "Archive a message by removing the INBOX label.",
|
|
15324
|
-
inputSchema: messageIdSchema,
|
|
15325
|
-
execute: async ({ context }, input) => modifyMessage(context.profile, getMessageId(input), undefined, ["INBOX"])
|
|
15326
|
-
},
|
|
15327
|
-
"messages.star": {
|
|
15328
|
-
summary: "Star a message.",
|
|
15329
|
-
inputSchema: messageIdSchema,
|
|
15330
|
-
execute: async ({ context }, input) => modifyMessage(context.profile, getMessageId(input), ["STARRED"], undefined)
|
|
15331
|
-
},
|
|
15332
|
-
"messages.reply": {
|
|
15333
|
-
summary: "Reply to a Gmail message in the same thread.",
|
|
15334
|
-
inputSchema: replySchema,
|
|
15335
|
-
execute: async ({ context }, input) => replyToMessage(context.profile, getMessageId(input), input)
|
|
15336
|
-
},
|
|
15337
|
-
"attachments.list": {
|
|
15338
|
-
summary: "List Gmail message attachments.",
|
|
15339
|
-
inputSchema: attachmentListSchema,
|
|
15340
|
-
execute: async ({ context }, input) => {
|
|
15341
|
-
const message = await requestJson(context.profile, `/users/me/messages/${encodeURIComponent(getMessageId(input))}`, { format: "full" });
|
|
15342
|
-
return collectAttachments(message.payload);
|
|
15343
|
-
}
|
|
15344
|
-
},
|
|
15345
|
-
"attachments.download": {
|
|
15346
|
-
summary: "Download one or all Gmail message attachments to disk.",
|
|
15347
|
-
inputSchema: attachmentDownloadSchema,
|
|
15348
|
-
execute: async ({ context }, input) => downloadAttachments(context.profile, input)
|
|
15349
|
-
},
|
|
15350
|
-
"labels.list": {
|
|
15351
|
-
summary: "List Gmail labels.",
|
|
15352
|
-
execute: async ({ context }) => requestJson(context.profile, "/users/me/labels", {})
|
|
15353
|
-
},
|
|
15354
|
-
"history.list": {
|
|
15355
|
-
summary: "List Gmail mailbox history from a history id.",
|
|
15356
|
-
inputSchema: historyListSchema,
|
|
15357
|
-
execute: async ({ context }, input) => requestJson(context.profile, "/users/me/history", {
|
|
15358
|
-
startHistoryId: input.startHistoryId,
|
|
15359
|
-
historyTypes: normalizeStringArray(input.historyTypes).join(",") || undefined,
|
|
15360
|
-
labelId: input.labelId,
|
|
15361
|
-
maxResults: input.maxResults,
|
|
15362
|
-
pageToken: input.pageToken
|
|
15363
|
-
})
|
|
15364
|
-
}
|
|
15365
|
-
}
|
|
15366
|
-
});
|
|
15367
|
-
async function modifyMessage(profile, messageId, addLabelIds, removeLabelIds) {
|
|
15368
|
-
return requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}/modify`, {}, {
|
|
15369
|
-
method: "POST",
|
|
15370
|
-
body: {
|
|
15371
|
-
addLabelIds: addLabelIds ?? [],
|
|
15372
|
-
removeLabelIds: removeLabelIds ?? []
|
|
15373
|
-
}
|
|
15374
|
-
});
|
|
15375
|
-
}
|
|
15376
|
-
async function replyToMessage(profile, messageId, input) {
|
|
15377
|
-
const original = await requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}`, { format: "full" });
|
|
15378
|
-
const headers = headersToObject(original.payload?.headers ?? []);
|
|
15379
|
-
const subject = normalizeReplySubject(headers.Subject ?? headers.subject ?? "");
|
|
15380
|
-
const to = headers.From ?? headers.from ?? "";
|
|
15381
|
-
const messageIdHeader = headers["Message-ID"] ?? headers["Message-Id"] ?? headers["message-id"] ?? "";
|
|
15382
|
-
const references = [headers.References ?? headers.references, messageIdHeader].filter(Boolean).join(" ");
|
|
15383
|
-
const raw = buildRawEmail({
|
|
15384
|
-
to,
|
|
15385
|
-
cc: normalizeStringArray(input.cc),
|
|
15386
|
-
bcc: normalizeStringArray(input.bcc),
|
|
15387
|
-
subject,
|
|
15388
|
-
body: input.body,
|
|
15389
|
-
isHtml: Boolean(input.html ?? input.isHtml),
|
|
15390
|
-
inReplyTo: messageIdHeader,
|
|
15391
|
-
references
|
|
15392
|
-
});
|
|
15393
|
-
return requestJson(profile, "/users/me/messages/send", {}, {
|
|
15394
|
-
method: "POST",
|
|
15395
|
-
body: {
|
|
15396
|
-
raw: Buffer.from(raw).toString("base64url"),
|
|
15397
|
-
threadId: original.threadId
|
|
15398
|
-
}
|
|
15399
|
-
});
|
|
15400
|
-
}
|
|
15401
|
-
async function downloadAttachments(profile, input) {
|
|
15402
|
-
const messageId = getMessageId(input);
|
|
15403
|
-
const outputDir = input.dir ?? input.outputDir ?? join9(configDirs()[0], "attachments", messageId);
|
|
15404
|
-
mkdirSync6(outputDir, { recursive: true });
|
|
15405
|
-
const attachments = input.attachmentId && input.filename ? [{
|
|
15406
|
-
attachmentId: input.attachmentId,
|
|
15407
|
-
filename: input.filename,
|
|
15408
|
-
mimeType: input.mimeType ?? "application/octet-stream",
|
|
15409
|
-
size: 0
|
|
15410
|
-
}] : collectAttachments((await requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}`, { format: "full" })).payload);
|
|
15411
|
-
const downloaded = [];
|
|
15412
|
-
for (const attachment of attachments) {
|
|
15413
|
-
const data = await requestJson(profile, `/users/me/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachment.attachmentId)}`, {});
|
|
15414
|
-
const filename = safeFilename(attachment.filename);
|
|
15415
|
-
const path = join9(outputDir, filename);
|
|
15416
|
-
const buffer = Buffer.from(data.data, "base64url");
|
|
15417
|
-
writeFileSync3(path, buffer);
|
|
15418
|
-
downloaded.push({
|
|
15419
|
-
filename,
|
|
15420
|
-
path,
|
|
15421
|
-
size: buffer.length,
|
|
15422
|
-
mimeType: attachment.mimeType
|
|
15423
|
-
});
|
|
15424
|
-
}
|
|
15425
|
-
return downloaded;
|
|
15426
|
-
}
|
|
15427
|
-
async function requestJson(profile, path, params, options = {}) {
|
|
15428
|
-
const token = await getValidAccessToken(profile);
|
|
15429
|
-
const url = new URL(`${GMAIL_API_BASE}${path}`);
|
|
15430
|
-
for (const [key, value] of Object.entries(params)) {
|
|
15431
|
-
if (value !== undefined && value !== null && value !== "")
|
|
15432
|
-
url.searchParams.append(key, String(value));
|
|
15433
|
-
}
|
|
15434
|
-
let lastError;
|
|
15435
|
-
for (let attempt = 0;attempt <= MAX_GMAIL_RETRIES; attempt++) {
|
|
15436
|
-
let response;
|
|
15437
|
-
try {
|
|
15438
|
-
response = await fetch(url, {
|
|
15439
|
-
method: options.method ?? "GET",
|
|
15440
|
-
headers: {
|
|
15441
|
-
Authorization: `Bearer ${token}`,
|
|
15442
|
-
Accept: "application/json",
|
|
15443
|
-
...options.body ? { "Content-Type": "application/json" } : {}
|
|
15444
|
-
},
|
|
15445
|
-
body: options.body ? JSON.stringify(options.body) : undefined
|
|
15446
|
-
});
|
|
15447
|
-
} catch (error2) {
|
|
15448
|
-
lastError = error2 instanceof Error ? error2.message : String(error2);
|
|
15449
|
-
if (attempt >= MAX_GMAIL_RETRIES)
|
|
15450
|
-
throw error2;
|
|
15451
|
-
await sleep(gmailBackoffDelayMs(attempt));
|
|
15452
|
-
continue;
|
|
15453
|
-
}
|
|
15454
|
-
const text = await response.text();
|
|
15455
|
-
const data = text ? JSON.parse(text) : {};
|
|
15456
|
-
if (response.ok)
|
|
15457
|
-
return data;
|
|
15458
|
-
const error = data;
|
|
15459
|
-
lastError = error.error?.message ?? response.statusText;
|
|
15460
|
-
if (!isRetryableGmailResponse(response.status, error) || attempt >= MAX_GMAIL_RETRIES) {
|
|
15461
|
-
throw new Error(`Gmail request failed (${response.status}): ${lastError}`);
|
|
15462
|
-
}
|
|
15463
|
-
await sleep(gmailBackoffDelayMs(attempt, response.headers.get("retry-after")));
|
|
15464
|
-
}
|
|
15465
|
-
throw new Error(`Gmail request failed: ${lastError ?? "unknown error"}`);
|
|
15466
|
-
}
|
|
15467
|
-
function isRetryableGmailResponse(status, error) {
|
|
15468
|
-
if ([429, 500, 502, 503, 504].includes(status))
|
|
15469
|
-
return true;
|
|
15470
|
-
const reasons = error.error?.errors?.map((entry) => entry.reason) ?? [];
|
|
15471
|
-
return reasons.some((reason) => reason === "rateLimitExceeded" || reason === "userRateLimitExceeded");
|
|
15472
|
-
}
|
|
15473
|
-
function gmailBackoffDelayMs(attempt, retryAfter = null) {
|
|
15474
|
-
if (retryAfter) {
|
|
15475
|
-
const seconds = Number(retryAfter);
|
|
15476
|
-
if (Number.isFinite(seconds) && seconds >= 0)
|
|
15477
|
-
return seconds * 1000;
|
|
15478
|
-
}
|
|
15479
|
-
const base = Number(process.env.CONNECTORS_GMAIL_RETRY_BASE_MS ?? "1000");
|
|
15480
|
-
const baseMs = Number.isFinite(base) && base >= 0 ? base : 1000;
|
|
15481
|
-
const jitterMs = Math.floor(Math.random() * 1000);
|
|
15482
|
-
return Math.min(2 ** attempt * baseMs + jitterMs, 64000);
|
|
15483
|
-
}
|
|
15484
|
-
function sleep(ms) {
|
|
15485
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15486
|
-
}
|
|
15487
|
-
async function getValidAccessToken(profile) {
|
|
15488
|
-
if (process.env.GMAIL_ACCESS_TOKEN)
|
|
15489
|
-
return process.env.GMAIL_ACCESS_TOKEN;
|
|
15490
|
-
const tokens = loadTokens(profile);
|
|
15491
|
-
if (!tokens?.accessToken && !tokens?.refreshToken) {
|
|
15492
|
-
throw new Error(`Gmail profile "${profile}" is not authenticated. Run: connectors auth gmail`);
|
|
15493
|
-
}
|
|
15494
|
-
if (tokens.accessToken && (!tokens.expiresAt || Date.now() < tokens.expiresAt - REFRESH_BUFFER_MS))
|
|
15495
|
-
return tokens.accessToken;
|
|
15496
|
-
if (!tokens.refreshToken)
|
|
15497
|
-
return tokens.accessToken ?? "";
|
|
15498
|
-
return (await refreshAccessToken(profile, tokens)).accessToken ?? "";
|
|
15499
|
-
}
|
|
15500
|
-
async function refreshAccessToken(profile, currentTokens) {
|
|
15501
|
-
const credentials = loadCredentials(profile);
|
|
15502
|
-
if (!credentials.clientId || !credentials.clientSecret)
|
|
15503
|
-
throw new Error("Gmail OAuth credentials are not configured. Run: connectors auth gmail");
|
|
15504
|
-
if (!currentTokens.refreshToken)
|
|
15505
|
-
throw new Error(`Gmail profile "${profile}" has no refresh token. Run: connectors auth gmail`);
|
|
15506
|
-
const response = await fetch(TOKEN_URL, {
|
|
15507
|
-
method: "POST",
|
|
15508
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
15509
|
-
body: new URLSearchParams({
|
|
15510
|
-
client_id: credentials.clientId,
|
|
15511
|
-
client_secret: credentials.clientSecret,
|
|
15512
|
-
refresh_token: currentTokens.refreshToken,
|
|
15513
|
-
grant_type: "refresh_token"
|
|
15514
|
-
})
|
|
15515
|
-
});
|
|
15516
|
-
const data = await response.json().catch(() => ({}));
|
|
15517
|
-
if (!response.ok || !data.access_token)
|
|
15518
|
-
throw new Error(`Gmail token refresh failed: ${data.error_description || data.error || response.statusText}`);
|
|
15519
|
-
const tokens = {
|
|
15520
|
-
accessToken: data.access_token,
|
|
15521
|
-
refreshToken: currentTokens.refreshToken,
|
|
15522
|
-
expiresAt: Date.now() + (data.expires_in ?? 3600) * 1000,
|
|
15523
|
-
tokenType: data.token_type ?? currentTokens.tokenType,
|
|
15524
|
-
scope: data.scope ?? currentTokens.scope
|
|
15525
|
-
};
|
|
15526
|
-
saveTokens(profile, tokens);
|
|
15527
|
-
return tokens;
|
|
15528
|
-
}
|
|
15529
|
-
function listProfiles() {
|
|
15530
|
-
const profiles = new Set;
|
|
15531
|
-
for (const baseDir of configDirs()) {
|
|
15532
|
-
const profilesDir = join9(baseDir, "profiles");
|
|
15533
|
-
if (!existsSync8(profilesDir))
|
|
15534
|
-
continue;
|
|
15535
|
-
for (const entry of readdirSync5(profilesDir, { withFileTypes: true })) {
|
|
15536
|
-
if (entry.isDirectory())
|
|
15537
|
-
profiles.add(entry.name);
|
|
15538
|
-
if (entry.isFile() && entry.name.endsWith(".json"))
|
|
15539
|
-
profiles.add(basename(entry.name, ".json"));
|
|
15540
|
-
}
|
|
15541
|
-
}
|
|
15542
|
-
return Array.from(profiles).sort((a, b) => a.localeCompare(b));
|
|
15543
|
-
}
|
|
15544
|
-
function loadCredentials(profile) {
|
|
15545
|
-
const envClientId = process.env.GMAIL_CLIENT_ID ?? process.env.GOOGLE_CLIENT_ID;
|
|
15546
|
-
const envClientSecret = process.env.GMAIL_CLIENT_SECRET ?? process.env.GOOGLE_CLIENT_SECRET;
|
|
15547
|
-
if (envClientId && envClientSecret)
|
|
15548
|
-
return { clientId: envClientId, clientSecret: envClientSecret };
|
|
15549
|
-
for (const baseDir of configDirs()) {
|
|
15550
|
-
const credentials = {
|
|
15551
|
-
...readJson(join9(baseDir, "credentials.json")),
|
|
15552
|
-
...readJson(join9(baseDir, "profiles", profile, "config.json"))
|
|
15553
|
-
};
|
|
15554
|
-
if (credentials.clientId || credentials.clientSecret)
|
|
15555
|
-
return credentials;
|
|
15556
|
-
}
|
|
15557
|
-
return {};
|
|
15558
|
-
}
|
|
15559
|
-
function loadTokens(profile) {
|
|
15560
|
-
for (const baseDir of configDirs()) {
|
|
15561
|
-
const fromProfile = readJson(join9(baseDir, "profiles", profile, "tokens.json"));
|
|
15562
|
-
if (fromProfile)
|
|
15563
|
-
return fromProfile;
|
|
15564
|
-
const flat = readJson(join9(baseDir, "profiles", `${profile}.json`));
|
|
15565
|
-
if (flat)
|
|
15566
|
-
return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
|
|
15567
|
-
}
|
|
15568
|
-
return null;
|
|
15569
|
-
}
|
|
15570
|
-
function saveTokens(profile, tokens) {
|
|
15571
|
-
const baseDir = configDirs().find((dir) => existsSync8(dir)) ?? configDirs()[0];
|
|
15572
|
-
const profileDir = join9(baseDir, "profiles", profile);
|
|
15573
|
-
mkdirSync6(profileDir, { recursive: true });
|
|
15574
|
-
writeFileSync3(join9(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
15575
|
-
}
|
|
15576
|
-
function configDirs() {
|
|
15577
|
-
const explicit = process.env.HASNA_GMAIL_CONNECTOR_DIR ?? process.env.GMAIL_CONNECTOR_DIR;
|
|
15578
|
-
if (explicit)
|
|
15579
|
-
return [explicit];
|
|
15580
|
-
const baseDir = process.env.HASNA_CONNECTORS_DIR ?? join9(homedir8(), ".hasna", "connectors");
|
|
15581
|
-
return [join9(baseDir, "gmail"), join9(baseDir, "connect-gmail")];
|
|
15582
|
-
}
|
|
15583
|
-
function readJson(path) {
|
|
15584
|
-
if (!existsSync8(path))
|
|
15585
|
-
return null;
|
|
15586
|
-
try {
|
|
15587
|
-
return JSON.parse(readFileSync3(path, "utf8"));
|
|
15588
|
-
} catch {
|
|
15589
|
-
return null;
|
|
15590
|
-
}
|
|
15591
|
-
}
|
|
15592
|
-
function getMessageId(input) {
|
|
15593
|
-
const id = input.messageId ?? (input.args?.[0] != null ? String(input.args[0]) : undefined);
|
|
15594
|
-
if (!id)
|
|
15595
|
-
throw new Error("Gmail messageId is required");
|
|
15596
|
-
return id;
|
|
15597
|
-
}
|
|
15598
|
-
function headersToObject(headers) {
|
|
15599
|
-
const out = {};
|
|
15600
|
-
for (const header of headers)
|
|
15601
|
-
out[header.name] = header.value;
|
|
15602
|
-
return out;
|
|
15603
|
-
}
|
|
15604
|
-
function extractBody(message, preferHtml = false) {
|
|
15605
|
-
if (!message.payload)
|
|
15606
|
-
return "";
|
|
15607
|
-
const targetType = preferHtml ? "text/html" : "text/plain";
|
|
15608
|
-
const parts = [];
|
|
15609
|
-
collectTextParts(message.payload, parts);
|
|
15610
|
-
return parts.find((part) => part.mimeType === targetType)?.data ?? parts.find((part) => part.mimeType.startsWith("text/"))?.data ?? "";
|
|
15611
|
-
}
|
|
15612
|
-
function collectTextParts(part, results) {
|
|
15613
|
-
const mimeType = (part.mimeType ?? "").split(";")[0].trim().toLowerCase();
|
|
15614
|
-
if (part.body?.data && mimeType.startsWith("text/")) {
|
|
15615
|
-
results.push({ mimeType, data: Buffer.from(part.body.data, "base64url").toString("utf8") });
|
|
15616
|
-
}
|
|
15617
|
-
for (const child of part.parts ?? [])
|
|
15618
|
-
collectTextParts(child, results);
|
|
15619
|
-
}
|
|
15620
|
-
function collectAttachments(part, attachments = []) {
|
|
15621
|
-
if (!part)
|
|
15622
|
-
return attachments;
|
|
15623
|
-
if (part.body?.attachmentId && part.filename) {
|
|
15624
|
-
attachments.push({
|
|
15625
|
-
attachmentId: part.body.attachmentId,
|
|
15626
|
-
filename: part.filename,
|
|
15627
|
-
mimeType: part.mimeType ?? "application/octet-stream",
|
|
15628
|
-
size: part.body.size ?? 0,
|
|
15629
|
-
partId: part.partId
|
|
15630
|
-
});
|
|
15631
|
-
}
|
|
15632
|
-
for (const child of part.parts ?? [])
|
|
15633
|
-
collectAttachments(child, attachments);
|
|
15634
|
-
return attachments;
|
|
15635
|
-
}
|
|
15636
|
-
function normalizeStringArray(value) {
|
|
15637
|
-
if (!value)
|
|
15638
|
-
return [];
|
|
15639
|
-
return Array.isArray(value) ? value : value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
15640
|
-
}
|
|
15641
|
-
function normalizeReplySubject(subject) {
|
|
15642
|
-
return subject.toLowerCase().startsWith("re:") ? subject : `Re: ${subject}`;
|
|
15643
|
-
}
|
|
15644
|
-
function buildRawEmail(input) {
|
|
15645
|
-
const headers = [
|
|
15646
|
-
`To: ${input.to}`,
|
|
15647
|
-
input.cc.length ? `Cc: ${input.cc.join(", ")}` : "",
|
|
15648
|
-
input.bcc.length ? `Bcc: ${input.bcc.join(", ")}` : "",
|
|
15649
|
-
`Subject: ${input.subject}`,
|
|
15650
|
-
input.inReplyTo ? `In-Reply-To: ${input.inReplyTo}` : "",
|
|
15651
|
-
input.references ? `References: ${input.references}` : "",
|
|
15652
|
-
"MIME-Version: 1.0",
|
|
15653
|
-
`Content-Type: ${input.isHtml ? "text/html" : "text/plain"}; charset=UTF-8`
|
|
15654
|
-
].filter(Boolean);
|
|
15655
|
-
return `${headers.join(`\r
|
|
15656
|
-
`)}\r
|
|
15657
|
-
\r
|
|
15658
|
-
${input.body}`;
|
|
15659
|
-
}
|
|
15660
|
-
function safeFilename(filename) {
|
|
15661
|
-
return basename(filename.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ")).replace(/[\/\\]/g, "_");
|
|
15662
|
-
}
|
|
15663
|
-
|
|
15664
|
-
// src/core/connectors/googledrive.ts
|
|
15665
|
-
import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync4, readdirSync as readdirSync6, writeFileSync as writeFileSync4 } from "fs";
|
|
15666
|
-
import { homedir as homedir9 } from "os";
|
|
15667
|
-
import { basename as basename2, join as join10 } from "path";
|
|
15668
|
-
var DRIVE_API_BASE = "https://www.googleapis.com/drive/v3";
|
|
15669
|
-
var TOKEN_URL2 = "https://oauth2.googleapis.com/token";
|
|
15670
|
-
var REFRESH_BUFFER_MS2 = 5 * 60 * 1000;
|
|
15671
|
-
var DEFAULT_FILE_FIELDS = [
|
|
15672
|
-
"id",
|
|
15673
|
-
"name",
|
|
15674
|
-
"mimeType",
|
|
15675
|
-
"parents",
|
|
15676
|
-
"version",
|
|
15677
|
-
"md5Checksum",
|
|
15678
|
-
"size",
|
|
15679
|
-
"modifiedTime",
|
|
15680
|
-
"createdTime",
|
|
15681
|
-
"trashed",
|
|
15682
|
-
"webViewLink",
|
|
15683
|
-
"webContentLink"
|
|
15684
|
-
].join(",");
|
|
15685
|
-
var DEFAULT_EXPORT_FORMATS = {
|
|
15686
|
-
document: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
15687
|
-
spreadsheet: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
15688
|
-
presentation: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
15689
|
-
drawing: "image/png"
|
|
15690
|
-
};
|
|
15691
|
-
var EXPORT_EXTENSIONS = {
|
|
15692
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": ".docx",
|
|
15693
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ".xlsx",
|
|
15694
|
-
"application/vnd.openxmlformats-officedocument.presentationml.presentation": ".pptx",
|
|
15695
|
-
"application/pdf": ".pdf",
|
|
15696
|
-
"text/plain": ".txt",
|
|
15697
|
-
"text/csv": ".csv",
|
|
15698
|
-
"image/png": ".png",
|
|
15699
|
-
"image/jpeg": ".jpg",
|
|
15700
|
-
"image/svg+xml": ".svg"
|
|
15701
|
-
};
|
|
15702
|
-
var listFilesSchema = exports_external2.object({
|
|
15703
|
-
pageSize: exports_external2.coerce.number().int().positive().max(1000).optional(),
|
|
15704
|
-
pageToken: exports_external2.string().optional(),
|
|
15705
|
-
q: exports_external2.string().optional(),
|
|
15706
|
-
fields: exports_external2.string().optional(),
|
|
15707
|
-
orderBy: exports_external2.string().optional(),
|
|
15708
|
-
corpora: exports_external2.enum(["user", "drive", "allDrives"]).optional(),
|
|
15709
|
-
driveId: exports_external2.string().optional(),
|
|
15710
|
-
supportsAllDrives: exports_external2.boolean().optional(),
|
|
15711
|
-
includeItemsFromAllDrives: exports_external2.boolean().optional()
|
|
15712
|
-
});
|
|
15713
|
-
var listDrivesSchema = exports_external2.object({
|
|
15714
|
-
pageSize: exports_external2.coerce.number().int().positive().max(100).optional(),
|
|
15715
|
-
pageToken: exports_external2.string().optional(),
|
|
15716
|
-
q: exports_external2.string().optional()
|
|
15717
|
-
});
|
|
15718
|
-
var fileIdSchema = exports_external2.object({
|
|
15719
|
-
fileId: exports_external2.string(),
|
|
15720
|
-
fields: exports_external2.string().optional()
|
|
15721
|
-
});
|
|
15722
|
-
var downloadSchema = exports_external2.object({
|
|
15723
|
-
fileId: exports_external2.string(),
|
|
15724
|
-
file: exports_external2.object({
|
|
15725
|
-
id: exports_external2.string(),
|
|
15726
|
-
name: exports_external2.string(),
|
|
15727
|
-
mimeType: exports_external2.string()
|
|
15728
|
-
}).optional(),
|
|
15729
|
-
exportMimeType: exports_external2.string().optional()
|
|
15730
|
-
});
|
|
15731
|
-
var profilesStatusSchema = exports_external2.object({
|
|
15732
|
-
profile: exports_external2.string().optional()
|
|
15733
|
-
});
|
|
15734
|
-
var googleDriveConnector = defineConnector({
|
|
15735
|
-
meta: {
|
|
15736
|
-
name: "googledrive",
|
|
15737
|
-
displayName: "Google Drive",
|
|
15738
|
-
description: "Profile-aware Google Drive discovery and file download operations.",
|
|
15739
|
-
category: "storage",
|
|
15740
|
-
tags: ["google", "drive", "files", "storage"]
|
|
15741
|
-
},
|
|
15742
|
-
auth: {
|
|
15743
|
-
type: "oauth2",
|
|
15744
|
-
supportsProfiles: true,
|
|
15745
|
-
fields: [
|
|
15746
|
-
{ key: "clientId", env: "GOOGLE_CLIENT_ID", label: "OAuth client ID" },
|
|
15747
|
-
{ key: "clientSecret", env: "GOOGLE_CLIENT_SECRET", label: "OAuth client secret", secret: true }
|
|
15748
|
-
]
|
|
15749
|
-
},
|
|
15750
|
-
createContext: ({ profile }) => ({ profile: profile || "default" }),
|
|
15751
|
-
operations: {
|
|
15752
|
-
"profiles.list": {
|
|
15753
|
-
summary: "List configured Google Drive profiles.",
|
|
15754
|
-
execute: () => ({ profiles: listProfiles2() })
|
|
15755
|
-
},
|
|
15756
|
-
"profiles.status": {
|
|
15757
|
-
summary: "List Google Drive profile authentication status.",
|
|
15758
|
-
inputSchema: profilesStatusSchema,
|
|
15759
|
-
execute: (_ctx, input) => ({ profiles: listProfileStatuses(input.profile) })
|
|
15760
|
-
},
|
|
15761
|
-
"files.list": {
|
|
15762
|
-
summary: "List Google Drive files.",
|
|
15763
|
-
inputSchema: listFilesSchema,
|
|
15764
|
-
execute: async ({ context }, input) => requestJson2(context.profile, "/files", {
|
|
15765
|
-
pageSize: input.pageSize ?? 1000,
|
|
15766
|
-
pageToken: input.pageToken,
|
|
15767
|
-
q: input.q,
|
|
15768
|
-
fields: input.fields ?? `nextPageToken,files(${DEFAULT_FILE_FIELDS})`,
|
|
15769
|
-
orderBy: input.orderBy ?? "modifiedTime desc",
|
|
15770
|
-
corpora: input.corpora,
|
|
15771
|
-
driveId: input.driveId,
|
|
15772
|
-
supportsAllDrives: input.supportsAllDrives ?? true,
|
|
15773
|
-
includeItemsFromAllDrives: input.includeItemsFromAllDrives ?? false
|
|
15774
|
-
})
|
|
15775
|
-
},
|
|
15776
|
-
"files.get": {
|
|
15777
|
-
summary: "Get Google Drive file metadata.",
|
|
15778
|
-
inputSchema: fileIdSchema,
|
|
15779
|
-
execute: async ({ context }, input) => requestJson2(context.profile, `/files/${encodeURIComponent(input.fileId)}`, {
|
|
15780
|
-
fields: input.fields ?? DEFAULT_FILE_FIELDS,
|
|
15781
|
-
supportsAllDrives: true
|
|
15782
|
-
})
|
|
15783
|
-
},
|
|
15784
|
-
"files.download": {
|
|
15785
|
-
summary: "Download or export a Google Drive file as base64 content.",
|
|
15786
|
-
inputSchema: downloadSchema,
|
|
15787
|
-
execute: async ({ context }, input) => {
|
|
15788
|
-
const file = input.file ?? await requestJson2(context.profile, `/files/${encodeURIComponent(input.fileId)}`, { fields: DEFAULT_FILE_FIELDS, supportsAllDrives: true });
|
|
15789
|
-
const exportMimeType = file.mimeType.startsWith("application/vnd.google-apps.") ? input.exportMimeType ?? defaultExportMimeType(file.mimeType) : undefined;
|
|
15790
|
-
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 });
|
|
15791
|
-
const mimeType = exportMimeType ?? file.mimeType ?? "application/octet-stream";
|
|
15792
|
-
return {
|
|
15793
|
-
dataBase64: Buffer.from(data).toString("base64"),
|
|
15794
|
-
filename: exportMimeType ? `${file.name}${extensionForMimeType(exportMimeType)}` : file.name,
|
|
15795
|
-
mimeType
|
|
15796
|
-
};
|
|
15797
|
-
}
|
|
15798
|
-
},
|
|
15799
|
-
"drives.list": {
|
|
15800
|
-
summary: "List Google shared drives.",
|
|
15801
|
-
inputSchema: listDrivesSchema,
|
|
15802
|
-
execute: async ({ context }, input) => requestJson2(context.profile, "/drives", {
|
|
15803
|
-
pageSize: input.pageSize ?? 100,
|
|
15804
|
-
pageToken: input.pageToken,
|
|
15805
|
-
q: input.q
|
|
15806
|
-
})
|
|
15807
|
-
}
|
|
15808
|
-
}
|
|
15809
|
-
});
|
|
15810
|
-
async function requestJson2(profile, path, params) {
|
|
15811
|
-
const response = await request(profile, path, params);
|
|
15812
|
-
const text = await response.text();
|
|
15813
|
-
return text ? JSON.parse(text) : {};
|
|
15814
|
-
}
|
|
15815
|
-
async function requestBinary(profile, path, params) {
|
|
15816
|
-
return (await request(profile, path, params)).arrayBuffer();
|
|
15817
|
-
}
|
|
15818
|
-
async function request(profile, path, params) {
|
|
15819
|
-
const token = await getValidAccessToken2(profile);
|
|
15820
|
-
const url = new URL(`${DRIVE_API_BASE}${path}`);
|
|
15821
|
-
for (const [key, value] of Object.entries(params)) {
|
|
15822
|
-
if (value !== undefined && value !== null && value !== "")
|
|
15823
|
-
url.searchParams.set(key, String(value));
|
|
15824
|
-
}
|
|
15825
|
-
const response = await fetch(url, { headers: { Authorization: `Bearer ${token}`, Accept: "application/json" } });
|
|
15826
|
-
if (!response.ok) {
|
|
15827
|
-
const body = await response.text().catch(() => "");
|
|
15828
|
-
throw new Error(`Google Drive request failed (${response.status}): ${extractGoogleError(body) || response.statusText}`);
|
|
15829
|
-
}
|
|
15830
|
-
return response;
|
|
15831
|
-
}
|
|
15832
|
-
async function getValidAccessToken2(profile) {
|
|
15833
|
-
if (process.env.GOOGLE_ACCESS_TOKEN)
|
|
15834
|
-
return process.env.GOOGLE_ACCESS_TOKEN;
|
|
15835
|
-
const tokens = loadTokens2(profile);
|
|
15836
|
-
if (!tokens?.accessToken && !tokens?.refreshToken) {
|
|
15837
|
-
throw new Error(`Google Drive profile "${profile}" is not authenticated. Run: connectors auth googledrive`);
|
|
15838
|
-
}
|
|
15839
|
-
if (tokens.accessToken && (!tokens.expiresAt || Date.now() < tokens.expiresAt - REFRESH_BUFFER_MS2))
|
|
15840
|
-
return tokens.accessToken;
|
|
15841
|
-
if (!tokens.refreshToken)
|
|
15842
|
-
return tokens.accessToken ?? "";
|
|
15843
|
-
return (await refreshAccessToken2(profile, tokens)).accessToken ?? "";
|
|
15844
|
-
}
|
|
15845
|
-
async function refreshAccessToken2(profile, currentTokens) {
|
|
15846
|
-
const credentials = loadCredentials2(profile);
|
|
15847
|
-
if (!credentials.clientId || !credentials.clientSecret)
|
|
15848
|
-
throw new Error("Google Drive OAuth credentials are not configured. Run: connectors auth googledrive");
|
|
15849
|
-
if (!currentTokens.refreshToken)
|
|
15850
|
-
throw new Error(`Google Drive profile "${profile}" has no refresh token. Run: connectors auth googledrive`);
|
|
15851
|
-
const response = await fetch(TOKEN_URL2, {
|
|
15852
|
-
method: "POST",
|
|
15853
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
15854
|
-
body: new URLSearchParams({
|
|
15855
|
-
client_id: credentials.clientId,
|
|
15856
|
-
client_secret: credentials.clientSecret,
|
|
15857
|
-
refresh_token: currentTokens.refreshToken,
|
|
15858
|
-
grant_type: "refresh_token"
|
|
15859
|
-
})
|
|
15860
|
-
});
|
|
15861
|
-
const data = await response.json().catch(() => ({}));
|
|
15862
|
-
if (!response.ok || !data.access_token)
|
|
15863
|
-
throw new Error(`Google Drive token refresh failed: ${data.error_description || data.error || response.statusText}`);
|
|
15864
|
-
const tokens = {
|
|
15865
|
-
accessToken: data.access_token,
|
|
15866
|
-
refreshToken: currentTokens.refreshToken,
|
|
15867
|
-
expiresAt: Date.now() + (data.expires_in ?? 3600) * 1000,
|
|
15868
|
-
tokenType: data.token_type ?? currentTokens.tokenType,
|
|
15869
|
-
scope: data.scope ?? currentTokens.scope
|
|
15870
|
-
};
|
|
15871
|
-
saveTokens2(profile, tokens);
|
|
15872
|
-
return tokens;
|
|
15873
|
-
}
|
|
15874
|
-
function listProfiles2() {
|
|
15875
|
-
const profiles = new Set;
|
|
15876
|
-
for (const baseDir of configDirs2()) {
|
|
15877
|
-
const profilesDir = join10(baseDir, "profiles");
|
|
15878
|
-
if (!existsSync9(profilesDir))
|
|
15879
|
-
continue;
|
|
15880
|
-
for (const entry of readdirSync6(profilesDir, { withFileTypes: true })) {
|
|
15881
|
-
if (entry.isDirectory())
|
|
15882
|
-
profiles.add(entry.name);
|
|
15883
|
-
if (entry.isFile() && entry.name.endsWith(".json"))
|
|
15884
|
-
profiles.add(basename2(entry.name, ".json"));
|
|
15885
|
-
}
|
|
15886
|
-
}
|
|
15887
|
-
return Array.from(profiles).sort((a, b) => a.localeCompare(b));
|
|
15888
|
-
}
|
|
15889
|
-
function listProfileStatuses(profile) {
|
|
15890
|
-
const profiles = profile ? [profile] : listProfiles2();
|
|
15891
|
-
const uniqueProfiles = profiles.length ? profiles : ["default"];
|
|
15892
|
-
const now3 = Date.now();
|
|
15893
|
-
return uniqueProfiles.map((name) => {
|
|
15894
|
-
const tokens = loadTokens2(name);
|
|
15895
|
-
const credentials = loadCredentials2(name);
|
|
15896
|
-
const hasAccessToken = Boolean(tokens?.accessToken || process.env.GOOGLE_ACCESS_TOKEN);
|
|
15897
|
-
const hasRefreshToken = Boolean(tokens?.refreshToken);
|
|
15898
|
-
const hasOAuthCredentials = Boolean(credentials.clientId && credentials.clientSecret);
|
|
15899
|
-
const expiresAt = tokens?.expiresAt ?? null;
|
|
15900
|
-
const expired = Boolean(expiresAt && now3 >= expiresAt - REFRESH_BUFFER_MS2);
|
|
15901
|
-
const authenticated = Boolean(process.env.GOOGLE_ACCESS_TOKEN || hasRefreshToken || hasAccessToken && !expired);
|
|
15902
|
-
const configured = authenticated || hasOAuthCredentials;
|
|
15903
|
-
const authRequired = !authenticated || expired && !hasRefreshToken;
|
|
15904
|
-
return {
|
|
15905
|
-
profile: name,
|
|
15906
|
-
configured,
|
|
15907
|
-
authenticated,
|
|
15908
|
-
expired,
|
|
15909
|
-
expiresAt,
|
|
15910
|
-
hasAccessToken,
|
|
15911
|
-
hasRefreshToken,
|
|
15912
|
-
hasOAuthCredentials,
|
|
15913
|
-
authRequired,
|
|
15914
|
-
message: authRequired ? `Google Drive profile "${name}" needs authentication. Run: connectors auth googledrive` : expired ? `Google Drive profile "${name}" access token is expired but can refresh.` : `Google Drive profile "${name}" is authenticated.`
|
|
15915
|
-
};
|
|
15916
|
-
});
|
|
15917
|
-
}
|
|
15918
|
-
function loadCredentials2(profile) {
|
|
15919
|
-
const envClientId = process.env.GOOGLE_CLIENT_ID;
|
|
15920
|
-
const envClientSecret = process.env.GOOGLE_CLIENT_SECRET;
|
|
15921
|
-
if (envClientId && envClientSecret)
|
|
15922
|
-
return { clientId: envClientId, clientSecret: envClientSecret };
|
|
15923
|
-
for (const baseDir of configDirs2()) {
|
|
15924
|
-
const credentials = {
|
|
15925
|
-
...readJson2(join10(baseDir, "credentials.json")),
|
|
15926
|
-
...readJson2(join10(baseDir, "profiles", profile, "config.json"))
|
|
15927
|
-
};
|
|
15928
|
-
if (credentials.clientId || credentials.clientSecret)
|
|
15929
|
-
return credentials;
|
|
15930
|
-
}
|
|
15931
|
-
return {};
|
|
15932
|
-
}
|
|
15933
|
-
function loadTokens2(profile) {
|
|
15934
|
-
for (const baseDir of configDirs2()) {
|
|
15935
|
-
const fromProfile = readJson2(join10(baseDir, "profiles", profile, "tokens.json"));
|
|
15936
|
-
if (fromProfile)
|
|
15937
|
-
return fromProfile;
|
|
15938
|
-
const flat = readJson2(join10(baseDir, "profiles", `${profile}.json`));
|
|
15939
|
-
if (flat)
|
|
15940
|
-
return flat.tokens ?? (flat.accessToken || flat.refreshToken ? flat : null);
|
|
15941
|
-
}
|
|
15942
|
-
return null;
|
|
15943
|
-
}
|
|
15944
|
-
function saveTokens2(profile, tokens) {
|
|
15945
|
-
const baseDir = configDirs2().find((dir) => existsSync9(dir)) ?? configDirs2()[0];
|
|
15946
|
-
const profileDir = join10(baseDir, "profiles", profile);
|
|
15947
|
-
mkdirSync7(profileDir, { recursive: true });
|
|
15948
|
-
writeFileSync4(join10(profileDir, "tokens.json"), JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
15949
|
-
}
|
|
15950
|
-
function configDirs2() {
|
|
15951
|
-
const explicit = process.env.HASNA_GOOGLE_DRIVE_CONNECTOR_DIR ?? process.env.GOOGLE_DRIVE_CONNECTOR_DIR;
|
|
15952
|
-
if (explicit)
|
|
15953
|
-
return [explicit];
|
|
15954
|
-
const baseDir = process.env.HASNA_CONNECTORS_DIR ?? join10(homedir9(), ".hasna", "connectors");
|
|
15955
|
-
return [join10(baseDir, "googledrive"), join10(baseDir, "connect-googledrive")];
|
|
15956
|
-
}
|
|
15957
|
-
function readJson2(path) {
|
|
15958
|
-
if (!existsSync9(path))
|
|
15959
|
-
return null;
|
|
15960
|
-
try {
|
|
15961
|
-
return JSON.parse(readFileSync4(path, "utf8"));
|
|
15962
|
-
} catch {
|
|
15963
|
-
return null;
|
|
15964
|
-
}
|
|
15965
|
-
}
|
|
15966
|
-
function defaultExportMimeType(googleMimeType) {
|
|
15967
|
-
if (googleMimeType.endsWith(".document"))
|
|
15968
|
-
return DEFAULT_EXPORT_FORMATS.document;
|
|
15969
|
-
if (googleMimeType.endsWith(".spreadsheet"))
|
|
15970
|
-
return DEFAULT_EXPORT_FORMATS.spreadsheet;
|
|
15971
|
-
if (googleMimeType.endsWith(".presentation"))
|
|
15972
|
-
return DEFAULT_EXPORT_FORMATS.presentation;
|
|
15973
|
-
if (googleMimeType.endsWith(".drawing"))
|
|
15974
|
-
return DEFAULT_EXPORT_FORMATS.drawing;
|
|
15975
|
-
throw new Error(`Cannot export Google Workspace file type: ${googleMimeType}`);
|
|
15976
|
-
}
|
|
15977
|
-
function extensionForMimeType(mimeType) {
|
|
15978
|
-
return EXPORT_EXTENSIONS[mimeType] ?? "";
|
|
15979
|
-
}
|
|
15980
|
-
function extractGoogleError(body) {
|
|
15981
|
-
if (!body)
|
|
15982
|
-
return "";
|
|
15983
|
-
try {
|
|
15984
|
-
const parsed = JSON.parse(body);
|
|
15985
|
-
return parsed.error?.message ?? body;
|
|
15986
|
-
} catch {
|
|
15987
|
-
return body;
|
|
15988
|
-
}
|
|
15989
|
-
}
|
|
15990
15160
|
// package.json
|
|
15991
15161
|
var package_default = {
|
|
15992
15162
|
name: "@hasna/connectors",
|
|
15993
|
-
version: "1.3.
|
|
15163
|
+
version: "1.3.24",
|
|
15994
15164
|
description: "Open source connector library - Install API connectors with a single command",
|
|
15995
15165
|
type: "module",
|
|
15996
15166
|
bin: {
|
|
@@ -16078,114 +15248,17 @@ var package_default = {
|
|
|
16078
15248
|
|
|
16079
15249
|
// src/core/connectors/imessage.ts
|
|
16080
15250
|
import {
|
|
16081
|
-
existsSync as
|
|
16082
|
-
mkdirSync as
|
|
16083
|
-
readFileSync as
|
|
16084
|
-
readdirSync as
|
|
15251
|
+
existsSync as existsSync8,
|
|
15252
|
+
mkdirSync as mkdirSync6,
|
|
15253
|
+
readFileSync as readFileSync3,
|
|
15254
|
+
readdirSync as readdirSync5,
|
|
16085
15255
|
rmSync,
|
|
16086
|
-
statSync as
|
|
16087
|
-
writeFileSync as
|
|
15256
|
+
statSync as statSync2,
|
|
15257
|
+
writeFileSync as writeFileSync3
|
|
16088
15258
|
} from "fs";
|
|
16089
|
-
import { join as
|
|
16090
|
-
|
|
16091
|
-
// src/lib/connector-resolver.ts
|
|
15259
|
+
import { join as join9 } from "path";
|
|
16092
15260
|
init_database();
|
|
16093
|
-
|
|
16094
|
-
import { join as join11 } from "path";
|
|
16095
|
-
var LEGACY_CONNECTOR_PREFIX = "connect-";
|
|
16096
|
-
var CONNECTOR_NAME_RE2 = /^[a-z0-9-]+$/;
|
|
16097
|
-
function normalizeConnectorName(name) {
|
|
16098
|
-
const trimmed = name.trim().toLowerCase();
|
|
16099
|
-
return trimmed.startsWith(LEGACY_CONNECTOR_PREFIX) ? trimmed.slice(LEGACY_CONNECTOR_PREFIX.length) : trimmed;
|
|
16100
|
-
}
|
|
16101
|
-
function legacyConnectorName(name) {
|
|
16102
|
-
return `${LEGACY_CONNECTOR_PREFIX}${normalizeConnectorName(name)}`;
|
|
16103
|
-
}
|
|
16104
|
-
function resolveConnectorName(name) {
|
|
16105
|
-
const canonicalName = normalizeConnectorName(name);
|
|
16106
|
-
const legacyName = legacyConnectorName(canonicalName);
|
|
16107
|
-
return {
|
|
16108
|
-
input: name,
|
|
16109
|
-
canonicalName,
|
|
16110
|
-
legacyName,
|
|
16111
|
-
aliases: canonicalName === legacyName ? [canonicalName] : [canonicalName, legacyName],
|
|
16112
|
-
isLegacyInput: name.trim().toLowerCase().startsWith(LEGACY_CONNECTOR_PREFIX)
|
|
16113
|
-
};
|
|
16114
|
-
}
|
|
16115
|
-
function isValidConnectorName(name) {
|
|
16116
|
-
const trimmed = name.trim();
|
|
16117
|
-
if (trimmed !== trimmed.toLowerCase())
|
|
16118
|
-
return false;
|
|
16119
|
-
return CONNECTOR_NAME_RE2.test(normalizeConnectorName(trimmed));
|
|
16120
|
-
}
|
|
16121
|
-
function connectorPackageDirNames(name) {
|
|
16122
|
-
const { canonicalName, legacyName } = resolveConnectorName(name);
|
|
16123
|
-
if (!canonicalName)
|
|
16124
|
-
return [legacyName];
|
|
16125
|
-
return canonicalName === legacyName ? [canonicalName] : [canonicalName, legacyName];
|
|
16126
|
-
}
|
|
16127
|
-
function resolveConnectorPackagePath(connectorsDir, name) {
|
|
16128
|
-
const resolution = resolveConnectorName(name);
|
|
16129
|
-
const dirNames = connectorPackageDirNames(name);
|
|
16130
|
-
const checkedPaths = dirNames.map((dirName) => join11(connectorsDir, dirName));
|
|
16131
|
-
const existingPath = checkedPaths.find((path) => existsSync10(path)) ?? null;
|
|
16132
|
-
const existingDirName = existingPath ? dirNames[checkedPaths.indexOf(existingPath)] : null;
|
|
16133
|
-
return {
|
|
16134
|
-
...resolution,
|
|
16135
|
-
connectorsDir,
|
|
16136
|
-
preferredDirName: dirNames[0],
|
|
16137
|
-
preferredPath: checkedPaths[0],
|
|
16138
|
-
existingPath,
|
|
16139
|
-
existingDirName,
|
|
16140
|
-
checkedPaths
|
|
16141
|
-
};
|
|
16142
|
-
}
|
|
16143
|
-
function getConnectorPackagePath(connectorsDir, name) {
|
|
16144
|
-
const resolved = resolveConnectorPackagePath(connectorsDir, name);
|
|
16145
|
-
return resolved.existingPath ?? resolved.preferredPath;
|
|
16146
|
-
}
|
|
16147
|
-
function resolveConnectorConfigPaths(name, connectorsHome = getConnectorsHome()) {
|
|
16148
|
-
const resolution = resolveConnectorName(name);
|
|
16149
|
-
const preferredDirName = resolution.canonicalName || resolution.legacyName;
|
|
16150
|
-
const preferredPath = join11(connectorsHome, preferredDirName);
|
|
16151
|
-
const legacyPath = join11(connectorsHome, resolution.legacyName);
|
|
16152
|
-
const paths = preferredPath === legacyPath ? [preferredPath] : [preferredPath, legacyPath];
|
|
16153
|
-
const existingPaths = paths.filter((path) => existsSync10(path));
|
|
16154
|
-
return {
|
|
16155
|
-
...resolution,
|
|
16156
|
-
connectorsHome,
|
|
16157
|
-
preferredDirName,
|
|
16158
|
-
preferredPath,
|
|
16159
|
-
legacyPath,
|
|
16160
|
-
existingPaths,
|
|
16161
|
-
readPaths: paths
|
|
16162
|
-
};
|
|
16163
|
-
}
|
|
16164
|
-
function getConnectorConfigDir(name, connectorsHome = getConnectorsHome()) {
|
|
16165
|
-
return resolveConnectorConfigPaths(name, connectorsHome).preferredPath;
|
|
16166
|
-
}
|
|
16167
|
-
function getConnectorConfigReadDirs(name, connectorsHome = getConnectorsHome()) {
|
|
16168
|
-
return resolveConnectorConfigPaths(name, connectorsHome).readPaths;
|
|
16169
|
-
}
|
|
16170
|
-
function listConfiguredConnectorNames(connectorsHome = getConnectorsHome()) {
|
|
16171
|
-
if (!existsSync10(connectorsHome))
|
|
16172
|
-
return [];
|
|
16173
|
-
const names = new Set;
|
|
16174
|
-
for (const entry of readdirSync7(connectorsHome)) {
|
|
16175
|
-
const fullPath = join11(connectorsHome, entry);
|
|
16176
|
-
try {
|
|
16177
|
-
if (!statSync2(fullPath).isDirectory())
|
|
16178
|
-
continue;
|
|
16179
|
-
if (!isValidConnectorName(entry))
|
|
16180
|
-
continue;
|
|
16181
|
-
names.add(normalizeConnectorName(entry));
|
|
16182
|
-
} catch {}
|
|
16183
|
-
}
|
|
16184
|
-
return [...names].sort();
|
|
16185
|
-
}
|
|
16186
|
-
|
|
16187
|
-
// src/core/connectors/imessage.ts
|
|
16188
|
-
var CONNECTOR_NAME = "imessage";
|
|
15261
|
+
var CONNECTOR_DIRNAME = "connect-imessage";
|
|
16189
15262
|
var COMMAND_SPECS = [
|
|
16190
15263
|
{
|
|
16191
15264
|
name: "profile",
|
|
@@ -16309,7 +15382,7 @@ API Key authentication is optional and depends on the bridge deployment. A bridg
|
|
|
16309
15382
|
|
|
16310
15383
|
## Data Storage
|
|
16311
15384
|
|
|
16312
|
-
Connector state is stored under \`~/.hasna/connectors/imessage/\`. Profiles are read from both \`profiles/<name>.json\` and \`profiles/<name>/config.json\` so the connector stays compatible with the shared dashboard auth helpers while remaining fully internal to the one-product repo.
|
|
15385
|
+
Connector state is stored under \`~/.hasna/connectors/connect-imessage/\`. Profiles are read from both \`profiles/<name>.json\` and \`profiles/<name>/config.json\` so the connector stays compatible with the shared dashboard auth helpers while remaining fully internal to the one-product repo.
|
|
16313
15386
|
`;
|
|
16314
15387
|
var commandInputSchema = exports_external2.object({
|
|
16315
15388
|
args: exports_external2.array(exports_external2.string()).default([]),
|
|
@@ -16345,44 +15418,36 @@ var messageReplyInputSchema = exports_external2.object({
|
|
|
16345
15418
|
deviceId: exports_external2.string().optional()
|
|
16346
15419
|
});
|
|
16347
15420
|
function getConfigDir2() {
|
|
16348
|
-
return
|
|
16349
|
-
}
|
|
16350
|
-
function getConfigReadDirs() {
|
|
16351
|
-
return getConnectorConfigReadDirs(CONNECTOR_NAME);
|
|
15421
|
+
return join9(getConnectorsHome(), CONNECTOR_DIRNAME);
|
|
16352
15422
|
}
|
|
16353
15423
|
function getProfilesDir() {
|
|
16354
|
-
return
|
|
15424
|
+
return join9(getConfigDir2(), "profiles");
|
|
16355
15425
|
}
|
|
16356
15426
|
function getCurrentProfile() {
|
|
16357
|
-
|
|
16358
|
-
|
|
16359
|
-
|
|
16360
|
-
|
|
16361
|
-
|
|
16362
|
-
|
|
16363
|
-
|
|
16364
|
-
|
|
16365
|
-
}
|
|
15427
|
+
const currentProfileFile = join9(getConfigDir2(), "current_profile");
|
|
15428
|
+
if (!existsSync8(currentProfileFile)) {
|
|
15429
|
+
return "default";
|
|
15430
|
+
}
|
|
15431
|
+
try {
|
|
15432
|
+
return readFileSync3(currentProfileFile, "utf-8").trim() || "default";
|
|
15433
|
+
} catch {
|
|
15434
|
+
return "default";
|
|
16366
15435
|
}
|
|
16367
|
-
return "default";
|
|
16368
15436
|
}
|
|
16369
15437
|
function setCurrentProfile(profile) {
|
|
16370
15438
|
const configDir = getConfigDir2();
|
|
16371
|
-
|
|
16372
|
-
|
|
15439
|
+
mkdirSync6(configDir, { recursive: true });
|
|
15440
|
+
writeFileSync3(join9(configDir, "current_profile"), profile);
|
|
16373
15441
|
}
|
|
16374
15442
|
function getFlatProfilePath(profile) {
|
|
16375
|
-
return
|
|
15443
|
+
return join9(getProfilesDir(), `${profile}.json`);
|
|
16376
15444
|
}
|
|
16377
|
-
function
|
|
16378
|
-
return
|
|
16379
|
-
}
|
|
16380
|
-
function getDirectoryProfileReadPaths(profile) {
|
|
16381
|
-
return getConfigReadDirs().map((dir) => join12(dir, "profiles", profile, "config.json"));
|
|
15445
|
+
function getDirectoryProfilePath(profile) {
|
|
15446
|
+
return join9(getProfilesDir(), profile, "config.json");
|
|
16382
15447
|
}
|
|
16383
15448
|
function loadJsonFile(path) {
|
|
16384
15449
|
try {
|
|
16385
|
-
return JSON.parse(
|
|
15450
|
+
return JSON.parse(readFileSync3(path, "utf-8"));
|
|
16386
15451
|
} catch {
|
|
16387
15452
|
return {};
|
|
16388
15453
|
}
|
|
@@ -16398,8 +15463,8 @@ function sanitizeProfileConfig(config) {
|
|
|
16398
15463
|
};
|
|
16399
15464
|
}
|
|
16400
15465
|
function loadProfile(profile = getCurrentProfile()) {
|
|
16401
|
-
const flatConfig =
|
|
16402
|
-
const directoryConfig =
|
|
15466
|
+
const flatConfig = existsSync8(getFlatProfilePath(profile)) ? loadJsonFile(getFlatProfilePath(profile)) : {};
|
|
15467
|
+
const directoryConfig = existsSync8(getDirectoryProfilePath(profile)) ? loadJsonFile(getDirectoryProfilePath(profile)) : {};
|
|
16403
15468
|
return sanitizeProfileConfig({
|
|
16404
15469
|
...flatConfig,
|
|
16405
15470
|
...directoryConfig
|
|
@@ -16407,34 +15472,33 @@ function loadProfile(profile = getCurrentProfile()) {
|
|
|
16407
15472
|
}
|
|
16408
15473
|
function writeProfile(profile, config) {
|
|
16409
15474
|
const profilesDir = getProfilesDir();
|
|
16410
|
-
|
|
16411
|
-
|
|
15475
|
+
mkdirSync6(profilesDir, { recursive: true });
|
|
15476
|
+
writeFileSync3(getFlatProfilePath(profile), JSON.stringify(config, null, 2) + `
|
|
16412
15477
|
`);
|
|
16413
15478
|
}
|
|
16414
15479
|
function profileExists(profile) {
|
|
16415
15480
|
if (profile === "default") {
|
|
16416
15481
|
return true;
|
|
16417
15482
|
}
|
|
16418
|
-
return
|
|
15483
|
+
return existsSync8(getFlatProfilePath(profile)) || existsSync8(join9(getProfilesDir(), profile));
|
|
16419
15484
|
}
|
|
16420
|
-
function
|
|
15485
|
+
function listProfiles() {
|
|
15486
|
+
const profilesDir = getProfilesDir();
|
|
16421
15487
|
const seen = new Set(["default"]);
|
|
16422
|
-
|
|
16423
|
-
|
|
16424
|
-
if (!existsSync11(profilesDir))
|
|
16425
|
-
continue;
|
|
16426
|
-
try {
|
|
16427
|
-
for (const entry of readdirSync8(profilesDir)) {
|
|
16428
|
-
const fullPath = join12(profilesDir, entry);
|
|
16429
|
-
const stat = statSync3(fullPath);
|
|
16430
|
-
if (stat.isDirectory()) {
|
|
16431
|
-
seen.add(entry);
|
|
16432
|
-
} else if (entry.endsWith(".json")) {
|
|
16433
|
-
seen.add(entry.replace(/\.json$/, ""));
|
|
16434
|
-
}
|
|
16435
|
-
}
|
|
16436
|
-
} catch {}
|
|
15488
|
+
if (!existsSync8(profilesDir)) {
|
|
15489
|
+
return [...seen];
|
|
16437
15490
|
}
|
|
15491
|
+
try {
|
|
15492
|
+
for (const entry of readdirSync5(profilesDir)) {
|
|
15493
|
+
const fullPath = join9(profilesDir, entry);
|
|
15494
|
+
const stat = statSync2(fullPath);
|
|
15495
|
+
if (stat.isDirectory()) {
|
|
15496
|
+
seen.add(entry);
|
|
15497
|
+
} else if (entry.endsWith(".json")) {
|
|
15498
|
+
seen.add(entry.replace(/\.json$/, ""));
|
|
15499
|
+
}
|
|
15500
|
+
}
|
|
15501
|
+
} catch {}
|
|
16438
15502
|
return [...seen].sort();
|
|
16439
15503
|
}
|
|
16440
15504
|
function createProfile(profile, config = {}) {
|
|
@@ -16447,11 +15511,11 @@ function createProfile(profile, config = {}) {
|
|
|
16447
15511
|
}
|
|
16448
15512
|
function clearProfile(profile = getCurrentProfile()) {
|
|
16449
15513
|
const flatPath = getFlatProfilePath(profile);
|
|
16450
|
-
const directoryPath =
|
|
16451
|
-
if (
|
|
15514
|
+
const directoryPath = join9(getProfilesDir(), profile);
|
|
15515
|
+
if (existsSync8(flatPath)) {
|
|
16452
15516
|
rmSync(flatPath);
|
|
16453
15517
|
}
|
|
16454
|
-
if (
|
|
15518
|
+
if (existsSync8(directoryPath)) {
|
|
16455
15519
|
rmSync(directoryPath, { recursive: true, force: true });
|
|
16456
15520
|
}
|
|
16457
15521
|
}
|
|
@@ -16747,7 +15811,7 @@ async function sendMessage(context, input) {
|
|
|
16747
15811
|
direction: "outbound"
|
|
16748
15812
|
});
|
|
16749
15813
|
}
|
|
16750
|
-
async function
|
|
15814
|
+
async function replyToMessage(context, input) {
|
|
16751
15815
|
const payload = await bridgeRequest(context, "/messages/reply", {
|
|
16752
15816
|
method: "POST",
|
|
16753
15817
|
body: {
|
|
@@ -16861,7 +15925,7 @@ async function runProfileCommand2(args, context) {
|
|
|
16861
15925
|
switch (subcommand) {
|
|
16862
15926
|
case "list": {
|
|
16863
15927
|
const current = getCurrentProfile();
|
|
16864
|
-
const profiles =
|
|
15928
|
+
const profiles = listProfiles();
|
|
16865
15929
|
return successOutput({ current, profiles }, context.format, () => profiles.map((profile) => `${profile}${profile === current ? " (active)" : ""}`).join(`
|
|
16866
15930
|
`));
|
|
16867
15931
|
}
|
|
@@ -17035,7 +16099,7 @@ async function runMessageCommand(args, context) {
|
|
|
17035
16099
|
if (!conversationId || !text) {
|
|
17036
16100
|
return failure2("Usage: connect-imessage message reply --conversation <id> --text <text>");
|
|
17037
16101
|
}
|
|
17038
|
-
return successOutput(await
|
|
16102
|
+
return successOutput(await replyToMessage(resolved, {
|
|
17039
16103
|
conversationId,
|
|
17040
16104
|
text,
|
|
17041
16105
|
replyToMessageId: asString2(options.replyTo),
|
|
@@ -17193,7 +16257,7 @@ var imessageConnector = defineConnector({
|
|
|
17193
16257
|
summary: "Reply to an existing conversation through the bridge",
|
|
17194
16258
|
inputSchema: messageReplyInputSchema,
|
|
17195
16259
|
async execute({ context }, input) {
|
|
17196
|
-
return
|
|
16260
|
+
return replyToMessage(context, input);
|
|
17197
16261
|
}
|
|
17198
16262
|
}
|
|
17199
16263
|
},
|
|
@@ -17256,19 +16320,19 @@ var imessageConnector = defineConnector({
|
|
|
17256
16320
|
});
|
|
17257
16321
|
|
|
17258
16322
|
// src/core/connectors/stripe.ts
|
|
17259
|
-
import { existsSync as
|
|
17260
|
-
import { dirname as dirname4, join as
|
|
16323
|
+
import { existsSync as existsSync9 } from "fs";
|
|
16324
|
+
import { dirname as dirname4, join as join10 } from "path";
|
|
17261
16325
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
|
|
17262
16326
|
var __dirname3 = dirname4(fileURLToPath2(import.meta.url));
|
|
17263
16327
|
function resolveStripeConnectorDir() {
|
|
17264
16328
|
const candidates = [
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
16329
|
+
join10(__dirname3, "..", "..", "..", "connectors", "connect-stripe"),
|
|
16330
|
+
join10(__dirname3, "..", "..", "connectors", "connect-stripe"),
|
|
16331
|
+
join10(__dirname3, "..", "connectors", "connect-stripe"),
|
|
16332
|
+
join10(process.cwd(), "connectors", "connect-stripe")
|
|
17269
16333
|
];
|
|
17270
16334
|
for (const candidate of candidates) {
|
|
17271
|
-
if (
|
|
16335
|
+
if (existsSync9(candidate)) {
|
|
17272
16336
|
return candidate;
|
|
17273
16337
|
}
|
|
17274
16338
|
}
|
|
@@ -17507,10 +16571,10 @@ function buildCommandHelp2(spec) {
|
|
|
17507
16571
|
var ROOT_HELP3 = buildRootHelp2(COMMAND_SPECS2);
|
|
17508
16572
|
var COMMAND_HELP3 = Object.fromEntries(COMMAND_SPECS2.map((spec) => [spec.name, buildCommandHelp2(spec)]));
|
|
17509
16573
|
async function loadStripeApiModule() {
|
|
17510
|
-
return await import(pathToFileURL2(
|
|
16574
|
+
return await import(pathToFileURL2(join10(CONNECTOR_DIR2, "src", "api", "index.ts")).href);
|
|
17511
16575
|
}
|
|
17512
16576
|
async function loadStripeConfigModule() {
|
|
17513
|
-
return await import(pathToFileURL2(
|
|
16577
|
+
return await import(pathToFileURL2(join10(CONNECTOR_DIR2, "src", "utils", "config.ts")).href);
|
|
17514
16578
|
}
|
|
17515
16579
|
function extractGlobalArgs3(args) {
|
|
17516
16580
|
const remaining = [];
|
|
@@ -18122,9 +17186,7 @@ var stripeConnector = defineConnector({
|
|
|
18122
17186
|
|
|
18123
17187
|
// src/core/builtins.ts
|
|
18124
17188
|
var INTERNAL_CONNECTOR_DEFINITIONS = [
|
|
18125
|
-
gmailConnector,
|
|
18126
17189
|
githubConnector,
|
|
18127
|
-
googleDriveConnector,
|
|
18128
17190
|
imessageConnector,
|
|
18129
17191
|
stripeConnector
|
|
18130
17192
|
];
|
|
@@ -24120,25 +23182,6 @@ var connectors17 = [
|
|
|
24120
23182
|
];
|
|
24121
23183
|
|
|
24122
23184
|
// src/lib/registry.ts
|
|
24123
|
-
var CATEGORIES = [
|
|
24124
|
-
"AI & ML",
|
|
24125
|
-
"Developer Tools",
|
|
24126
|
-
"Design & Content",
|
|
24127
|
-
"Communication",
|
|
24128
|
-
"Social Media",
|
|
24129
|
-
"Commerce & Finance",
|
|
24130
|
-
"Google Workspace",
|
|
24131
|
-
"Data & Analytics",
|
|
24132
|
-
"Business Tools",
|
|
24133
|
-
"Patents & IP",
|
|
24134
|
-
"Advertising",
|
|
24135
|
-
"Security & Compliance",
|
|
24136
|
-
"Marketing & Sales",
|
|
24137
|
-
"Infrastructure",
|
|
24138
|
-
"Healthcare & Hospitality",
|
|
24139
|
-
"IoT & Messaging",
|
|
24140
|
-
"Database"
|
|
24141
|
-
];
|
|
24142
23185
|
var CONNECTORS = [
|
|
24143
23186
|
...connectors,
|
|
24144
23187
|
...connectors2,
|
|
@@ -24159,10 +23202,7 @@ var CONNECTORS = [
|
|
|
24159
23202
|
...connectors17
|
|
24160
23203
|
];
|
|
24161
23204
|
function getConnector(name) {
|
|
24162
|
-
|
|
24163
|
-
return;
|
|
24164
|
-
const normalizedName = normalizeConnectorName(name);
|
|
24165
|
-
return CONNECTORS.find((c) => c.name === normalizedName);
|
|
23205
|
+
return CONNECTORS.find((c) => c.name === name);
|
|
24166
23206
|
}
|
|
24167
23207
|
var versionsLoaded = false;
|
|
24168
23208
|
function loadConnectorVersions() {
|
|
@@ -24171,17 +23211,17 @@ function loadConnectorVersions() {
|
|
|
24171
23211
|
versionsLoaded = true;
|
|
24172
23212
|
const thisDir = dirname5(fileURLToPath3(import.meta.url));
|
|
24173
23213
|
const candidates = [
|
|
24174
|
-
|
|
24175
|
-
|
|
23214
|
+
join11(thisDir, "..", "connectors"),
|
|
23215
|
+
join11(thisDir, "..", "..", "connectors")
|
|
24176
23216
|
];
|
|
24177
|
-
const connectorsDir = candidates.find((d) =>
|
|
23217
|
+
const connectorsDir = candidates.find((d) => existsSync10(d));
|
|
24178
23218
|
if (!connectorsDir)
|
|
24179
23219
|
return;
|
|
24180
23220
|
for (const connector of CONNECTORS) {
|
|
24181
23221
|
try {
|
|
24182
|
-
const pkgPath =
|
|
24183
|
-
if (
|
|
24184
|
-
const pkg = JSON.parse(
|
|
23222
|
+
const pkgPath = join11(connectorsDir, `connect-${connector.name}`, "package.json");
|
|
23223
|
+
if (existsSync10(pkgPath)) {
|
|
23224
|
+
const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|
|
24185
23225
|
connector.version = pkg.version || "0.0.0";
|
|
24186
23226
|
continue;
|
|
24187
23227
|
}
|
|
@@ -24194,16 +23234,16 @@ function loadConnectorVersions() {
|
|
|
24194
23234
|
}
|
|
24195
23235
|
|
|
24196
23236
|
// src/lib/installer.ts
|
|
24197
|
-
import { existsSync as
|
|
24198
|
-
import { join as
|
|
23237
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync4, readdirSync as readdirSync6, statSync as statSync3, rmSync as rmSync2 } from "fs";
|
|
23238
|
+
import { join as join12, dirname as dirname6 } from "path";
|
|
24199
23239
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
24200
23240
|
var __dirname4 = dirname6(fileURLToPath4(import.meta.url));
|
|
24201
23241
|
function resolveConnectorsDir() {
|
|
24202
|
-
const fromBin =
|
|
24203
|
-
if (
|
|
23242
|
+
const fromBin = join12(__dirname4, "..", "connectors");
|
|
23243
|
+
if (existsSync11(fromBin))
|
|
24204
23244
|
return fromBin;
|
|
24205
|
-
const fromSrc =
|
|
24206
|
-
if (
|
|
23245
|
+
const fromSrc = join12(__dirname4, "..", "..", "connectors");
|
|
23246
|
+
if (existsSync11(fromSrc))
|
|
24207
23247
|
return fromSrc;
|
|
24208
23248
|
return fromBin;
|
|
24209
23249
|
}
|
|
@@ -24211,22 +23251,25 @@ var CONNECTORS_DIR = resolveConnectorsDir();
|
|
|
24211
23251
|
var PROJECT_CONNECTORS_DIRNAME = ".connectors";
|
|
24212
23252
|
var ENABLEMENT_MANIFEST_FILENAME = "manifest.json";
|
|
24213
23253
|
var ENABLEMENT_INDEX_FILENAME = "index.ts";
|
|
23254
|
+
function normalizeConnectorName(name) {
|
|
23255
|
+
return name.startsWith("connect-") ? name.slice("connect-".length) : name;
|
|
23256
|
+
}
|
|
24214
23257
|
function getProjectConnectorsDir(targetDir) {
|
|
24215
|
-
return
|
|
23258
|
+
return join12(targetDir, PROJECT_CONNECTORS_DIRNAME);
|
|
24216
23259
|
}
|
|
24217
23260
|
function getEnablementManifestPath(targetDir) {
|
|
24218
|
-
return
|
|
23261
|
+
return join12(getProjectConnectorsDir(targetDir), ENABLEMENT_MANIFEST_FILENAME);
|
|
24219
23262
|
}
|
|
24220
23263
|
function getLegacyInstallPath(targetDir, name) {
|
|
24221
|
-
return
|
|
23264
|
+
return join12(getProjectConnectorsDir(targetDir), `connect-${normalizeConnectorName(name)}`);
|
|
24222
23265
|
}
|
|
24223
23266
|
function loadEnablementManifest(targetDir) {
|
|
24224
23267
|
const manifestPath = getEnablementManifestPath(targetDir);
|
|
24225
|
-
if (!
|
|
23268
|
+
if (!existsSync11(manifestPath)) {
|
|
24226
23269
|
return null;
|
|
24227
23270
|
}
|
|
24228
23271
|
try {
|
|
24229
|
-
const raw = JSON.parse(
|
|
23272
|
+
const raw = JSON.parse(readFileSync5(manifestPath, "utf-8"));
|
|
24230
23273
|
if (!Array.isArray(raw.connectors)) {
|
|
24231
23274
|
return null;
|
|
24232
23275
|
}
|
|
@@ -24242,12 +23285,12 @@ function loadEnablementManifest(targetDir) {
|
|
|
24242
23285
|
}
|
|
24243
23286
|
function getLegacyInstalledConnectors(targetDir) {
|
|
24244
23287
|
const connectorsDir = getProjectConnectorsDir(targetDir);
|
|
24245
|
-
if (!
|
|
23288
|
+
if (!existsSync11(connectorsDir)) {
|
|
24246
23289
|
return [];
|
|
24247
23290
|
}
|
|
24248
|
-
return
|
|
24249
|
-
const fullPath =
|
|
24250
|
-
return entry.startsWith("connect-") &&
|
|
23291
|
+
return readdirSync6(connectorsDir).filter((entry) => {
|
|
23292
|
+
const fullPath = join12(connectorsDir, entry);
|
|
23293
|
+
return entry.startsWith("connect-") && statSync3(fullPath).isDirectory();
|
|
24251
23294
|
}).map((entry) => entry.replace("connect-", "")).sort();
|
|
24252
23295
|
}
|
|
24253
23296
|
function getEnabledConnectors(targetDir) {
|
|
@@ -24255,7 +23298,7 @@ function getEnabledConnectors(targetDir) {
|
|
|
24255
23298
|
return [...new Set([...manifestConnectors, ...getLegacyInstalledConnectors(targetDir)])].sort();
|
|
24256
23299
|
}
|
|
24257
23300
|
function updateConnectorsIndex(connectorsDir, connectors18) {
|
|
24258
|
-
const indexPath =
|
|
23301
|
+
const indexPath = join12(connectorsDir, ENABLEMENT_INDEX_FILENAME);
|
|
24259
23302
|
const connectorList = connectors18.map((connector) => ` "${connector}",`).join(`
|
|
24260
23303
|
`);
|
|
24261
23304
|
const content = `/**
|
|
@@ -24271,27 +23314,28 @@ ${connectorList}
|
|
|
24271
23314
|
|
|
24272
23315
|
export type EnabledConnectorName = typeof enabledConnectors[number];
|
|
24273
23316
|
`;
|
|
24274
|
-
|
|
23317
|
+
writeFileSync4(indexPath, content);
|
|
24275
23318
|
}
|
|
24276
23319
|
function writeEnablementManifest(targetDir, connectors18) {
|
|
24277
23320
|
const connectorsDir = getProjectConnectorsDir(targetDir);
|
|
24278
|
-
|
|
23321
|
+
mkdirSync7(connectorsDir, { recursive: true });
|
|
24279
23322
|
const manifest = {
|
|
24280
23323
|
version: 1,
|
|
24281
23324
|
mode: "internal",
|
|
24282
23325
|
updatedAt: new Date().toISOString(),
|
|
24283
23326
|
connectors: [...new Set(connectors18.map((value) => normalizeConnectorName(value)))].sort()
|
|
24284
23327
|
};
|
|
24285
|
-
|
|
23328
|
+
writeFileSync4(getEnablementManifestPath(targetDir), JSON.stringify(manifest, null, 2) + `
|
|
24286
23329
|
`);
|
|
24287
23330
|
updateConnectorsIndex(connectorsDir, manifest.connectors);
|
|
24288
23331
|
}
|
|
24289
23332
|
function getConnectorPath(name) {
|
|
24290
|
-
|
|
23333
|
+
const connectorName = name.startsWith("connect-") ? name : `connect-${name}`;
|
|
23334
|
+
return join12(CONNECTORS_DIR, connectorName);
|
|
24291
23335
|
}
|
|
24292
23336
|
function connectorExists(name) {
|
|
24293
23337
|
const normalizedName = normalizeConnectorName(name);
|
|
24294
|
-
return hasInternalConnectorDefinition(normalizedName) ||
|
|
23338
|
+
return hasInternalConnectorDefinition(normalizedName) || existsSync11(getConnectorPath(normalizedName));
|
|
24295
23339
|
}
|
|
24296
23340
|
function installConnector(name, options = {}) {
|
|
24297
23341
|
const { targetDir = process.cwd(), overwrite = false } = options;
|
|
@@ -24324,7 +23368,7 @@ function installConnector(name, options = {}) {
|
|
|
24324
23368
|
try {
|
|
24325
23369
|
const nextEnabled = [...new Set([...installed, normalizedName])].sort();
|
|
24326
23370
|
writeEnablementManifest(targetDir, nextEnabled);
|
|
24327
|
-
if (overwrite &&
|
|
23371
|
+
if (overwrite && existsSync11(legacyInstallPath)) {
|
|
24328
23372
|
rmSync2(legacyInstallPath, { recursive: true });
|
|
24329
23373
|
}
|
|
24330
23374
|
return {
|
|
@@ -24356,9 +23400,9 @@ function parseConnectorDocs(raw) {
|
|
|
24356
23400
|
function getConnectorDocs(name) {
|
|
24357
23401
|
const normalizedName = normalizeConnectorName(name);
|
|
24358
23402
|
const connectorPath = getConnectorPath(normalizedName);
|
|
24359
|
-
const claudeMdPath =
|
|
24360
|
-
if (
|
|
24361
|
-
return parseConnectorDocs(
|
|
23403
|
+
const claudeMdPath = join12(connectorPath, "CLAUDE.md");
|
|
23404
|
+
if (existsSync11(claudeMdPath)) {
|
|
23405
|
+
return parseConnectorDocs(readFileSync5(claudeMdPath, "utf-8"));
|
|
24362
23406
|
}
|
|
24363
23407
|
const internalDocs = getInternalConnectorDefinition(normalizedName)?.docsMarkdown;
|
|
24364
23408
|
if (internalDocs) {
|
|
@@ -24402,54 +23446,282 @@ function removeConnector(name, targetDir = process.cwd()) {
|
|
|
24402
23446
|
const nextEnabled = installed.filter((connector) => connector !== normalizedName);
|
|
24403
23447
|
writeEnablementManifest(targetDir, nextEnabled);
|
|
24404
23448
|
const legacyInstallPath = getLegacyInstallPath(targetDir, normalizedName);
|
|
24405
|
-
if (
|
|
23449
|
+
if (existsSync11(legacyInstallPath)) {
|
|
24406
23450
|
rmSync2(legacyInstallPath, { recursive: true });
|
|
24407
23451
|
}
|
|
24408
23452
|
return true;
|
|
24409
23453
|
}
|
|
24410
23454
|
|
|
24411
23455
|
// src/lib/runner.ts
|
|
24412
|
-
import { existsSync as
|
|
24413
|
-
import { join as
|
|
23456
|
+
import { existsSync as existsSync12, readdirSync as readdirSync7 } from "fs";
|
|
23457
|
+
import { join as join13, dirname as dirname7 } from "path";
|
|
24414
23458
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
24415
|
-
import { spawn as
|
|
23459
|
+
import { spawn as spawn3 } from "child_process";
|
|
24416
23460
|
init_database();
|
|
24417
|
-
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
|
|
24422
|
-
|
|
24423
|
-
|
|
24424
|
-
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
var
|
|
24428
|
-
|
|
24429
|
-
|
|
24430
|
-
|
|
24431
|
-
|
|
24432
|
-
|
|
23461
|
+
var __dirname5 = dirname7(fileURLToPath5(import.meta.url));
|
|
23462
|
+
function resolveConnectorsDir2() {
|
|
23463
|
+
const fromBin = join13(__dirname5, "..", "connectors");
|
|
23464
|
+
if (existsSync12(fromBin))
|
|
23465
|
+
return fromBin;
|
|
23466
|
+
const fromSrc = join13(__dirname5, "..", "..", "connectors");
|
|
23467
|
+
if (existsSync12(fromSrc))
|
|
23468
|
+
return fromSrc;
|
|
23469
|
+
return fromBin;
|
|
23470
|
+
}
|
|
23471
|
+
var CONNECTORS_DIR2 = resolveConnectorsDir2();
|
|
23472
|
+
function buildInternalHelpText(name, commands) {
|
|
23473
|
+
const lines = [
|
|
23474
|
+
`Usage: connect-${name} [options] [command]`,
|
|
23475
|
+
"",
|
|
23476
|
+
"Commands:"
|
|
23477
|
+
];
|
|
23478
|
+
for (const command of commands) {
|
|
23479
|
+
lines.push(` ${command.name.padEnd(24)} ${command.summary}`);
|
|
23480
|
+
}
|
|
23481
|
+
return lines.join(`
|
|
23482
|
+
`);
|
|
23483
|
+
}
|
|
23484
|
+
function getInternalCommandRuntime(name) {
|
|
23485
|
+
return getInternalConnectorDefinition(name)?.commandRuntime;
|
|
23486
|
+
}
|
|
23487
|
+
var ENV_VAR_NAME_OVERRIDES = {
|
|
23488
|
+
googlemaps: ["GOOGLE_MAPS"],
|
|
23489
|
+
googletasks: ["GOOGLE_TASKS", "GOOGLE"],
|
|
23490
|
+
google: ["GOOGLE"],
|
|
23491
|
+
stabilityai: ["STABILITY"],
|
|
23492
|
+
openweathermap: ["OPENWEATHERMAP", "OPENWEATHER"]
|
|
23493
|
+
};
|
|
23494
|
+
function buildEnvWithCredentials(connectorName, baseEnv) {
|
|
23495
|
+
const env = { ...baseEnv };
|
|
23496
|
+
const prefixes = ENV_VAR_NAME_OVERRIDES[connectorName] || [
|
|
23497
|
+
connectorName.toUpperCase().replace(/-/g, "_")
|
|
23498
|
+
];
|
|
23499
|
+
for (const prefix of prefixes) {
|
|
23500
|
+
const canonicalKey = `${prefix}_API_KEY`;
|
|
23501
|
+
if (env[canonicalKey])
|
|
23502
|
+
continue;
|
|
23503
|
+
const alternatives = [
|
|
23504
|
+
`HASNAXYZ_${prefix}_LIVE_API_KEY`,
|
|
23505
|
+
`HASNA_${prefix}_LIVE_API_KEY`,
|
|
23506
|
+
`${prefix}_LIVE_API_KEY`,
|
|
23507
|
+
`${prefix}_KEY`,
|
|
23508
|
+
`${prefix}_TOKEN`
|
|
23509
|
+
];
|
|
23510
|
+
for (const alt of alternatives) {
|
|
23511
|
+
const value = env[alt];
|
|
23512
|
+
if (value) {
|
|
23513
|
+
env[canonicalKey] = value;
|
|
23514
|
+
break;
|
|
23515
|
+
}
|
|
23516
|
+
}
|
|
23517
|
+
}
|
|
23518
|
+
return env;
|
|
23519
|
+
}
|
|
23520
|
+
function getConnectorCliPath(name) {
|
|
23521
|
+
const safeName = name.replace(/[^a-z0-9-]/g, "");
|
|
23522
|
+
const connectorDir = join13(CONNECTORS_DIR2, `connect-${safeName}`);
|
|
23523
|
+
const cliPath = join13(connectorDir, "src", "cli", "index.ts");
|
|
23524
|
+
if (existsSync12(cliPath))
|
|
23525
|
+
return cliPath;
|
|
23526
|
+
return null;
|
|
23527
|
+
}
|
|
23528
|
+
function hasConnectorCommandSurface(name) {
|
|
23529
|
+
return Boolean(getInternalCommandRuntime(name)?.commands.length || getConnectorCliPath(name));
|
|
23530
|
+
}
|
|
23531
|
+
function normalizeCommanderUsage(usage) {
|
|
23532
|
+
const commandToken = usage.trim().split(/\s+/)[0];
|
|
23533
|
+
if (!commandToken || commandToken === "help")
|
|
23534
|
+
return null;
|
|
23535
|
+
const aliases = commandToken.split("|").filter(Boolean);
|
|
23536
|
+
const [name, ...rest] = aliases;
|
|
23537
|
+
if (!name)
|
|
23538
|
+
return null;
|
|
23539
|
+
return {
|
|
23540
|
+
name,
|
|
23541
|
+
aliases: rest,
|
|
23542
|
+
usage: usage.trim()
|
|
23543
|
+
};
|
|
23544
|
+
}
|
|
23545
|
+
function parseCommanderHelpOperations(helpText) {
|
|
23546
|
+
const operations = [];
|
|
23547
|
+
const lines = helpText.split(`
|
|
23548
|
+
`);
|
|
23549
|
+
let inCommands = false;
|
|
23550
|
+
for (const line of lines) {
|
|
23551
|
+
if (line.trim().startsWith("Commands:")) {
|
|
23552
|
+
inCommands = true;
|
|
23553
|
+
continue;
|
|
23554
|
+
}
|
|
23555
|
+
if (!inCommands)
|
|
23556
|
+
continue;
|
|
23557
|
+
if (line.trim() === "") {
|
|
23558
|
+
if (operations.length > 0)
|
|
23559
|
+
inCommands = false;
|
|
23560
|
+
continue;
|
|
23561
|
+
}
|
|
23562
|
+
const row = line.match(/^ {2}(\S.*?)(?: {2,}(.+))?$/);
|
|
23563
|
+
if (!row)
|
|
23564
|
+
continue;
|
|
23565
|
+
const usage = row[1].trim();
|
|
23566
|
+
const summary = (row[2] ?? "").trim();
|
|
23567
|
+
const normalized = normalizeCommanderUsage(usage);
|
|
23568
|
+
if (!normalized)
|
|
23569
|
+
continue;
|
|
23570
|
+
operations.push({
|
|
23571
|
+
...normalized,
|
|
23572
|
+
summary,
|
|
23573
|
+
source: "cli"
|
|
23574
|
+
});
|
|
23575
|
+
}
|
|
23576
|
+
return operations;
|
|
23577
|
+
}
|
|
23578
|
+
function runConnectorCommand2(name, args, timeoutMs = 30000) {
|
|
23579
|
+
getConnectorsHome();
|
|
23580
|
+
const internalRuntime = getInternalCommandRuntime(name);
|
|
23581
|
+
if (internalRuntime?.run) {
|
|
23582
|
+
return Promise.resolve(internalRuntime.run(args)).then((result) => {
|
|
23583
|
+
if (result) {
|
|
23584
|
+
const stdout = result.stdout.trim();
|
|
23585
|
+
const stderr = (result.stderr ?? "").trim();
|
|
23586
|
+
const exitCode = result.exitCode ?? (result.success === false ? 1 : 0);
|
|
23587
|
+
return {
|
|
23588
|
+
stdout,
|
|
23589
|
+
stderr,
|
|
23590
|
+
exitCode,
|
|
23591
|
+
success: result.success ?? exitCode === 0
|
|
23592
|
+
};
|
|
23593
|
+
}
|
|
23594
|
+
return runLegacyConnectorCommand(name, args, timeoutMs);
|
|
23595
|
+
});
|
|
23596
|
+
}
|
|
23597
|
+
return runLegacyConnectorCommand(name, args, timeoutMs);
|
|
23598
|
+
}
|
|
23599
|
+
function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
23600
|
+
const cliPath = getConnectorCliPath(name);
|
|
23601
|
+
if (!cliPath) {
|
|
23602
|
+
return Promise.resolve({
|
|
23603
|
+
stdout: "",
|
|
23604
|
+
stderr: `Connector '${name}' not found or has no CLI.`,
|
|
23605
|
+
exitCode: 1,
|
|
23606
|
+
success: false
|
|
23607
|
+
});
|
|
23608
|
+
}
|
|
23609
|
+
return new Promise((resolve) => {
|
|
23610
|
+
const proc = spawn3("bun", ["run", cliPath, ...args], {
|
|
23611
|
+
timeout: timeoutMs,
|
|
23612
|
+
env: buildEnvWithCredentials(name, process.env),
|
|
23613
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
23614
|
+
});
|
|
23615
|
+
let stdout = "";
|
|
23616
|
+
let stderr = "";
|
|
23617
|
+
proc.stdout.on("data", (data) => {
|
|
23618
|
+
stdout += data.toString();
|
|
23619
|
+
});
|
|
23620
|
+
proc.stderr.on("data", (data) => {
|
|
23621
|
+
stderr += data.toString();
|
|
23622
|
+
});
|
|
23623
|
+
proc.on("close", (code) => {
|
|
23624
|
+
resolve({
|
|
23625
|
+
stdout: stdout.trim(),
|
|
23626
|
+
stderr: stderr.trim(),
|
|
23627
|
+
exitCode: code ?? 1,
|
|
23628
|
+
success: code === 0
|
|
23629
|
+
});
|
|
23630
|
+
});
|
|
23631
|
+
proc.on("error", (err) => {
|
|
23632
|
+
resolve({
|
|
23633
|
+
stdout: "",
|
|
23634
|
+
stderr: err.message,
|
|
23635
|
+
exitCode: 1,
|
|
23636
|
+
success: false
|
|
23637
|
+
});
|
|
23638
|
+
});
|
|
23639
|
+
});
|
|
23640
|
+
}
|
|
23641
|
+
async function getConnectorOperations(name) {
|
|
23642
|
+
const internalRuntime = getInternalCommandRuntime(name);
|
|
23643
|
+
if (internalRuntime?.commands.length) {
|
|
23644
|
+
const operations2 = internalRuntime.commands.map((command) => ({
|
|
23645
|
+
name: command.name,
|
|
23646
|
+
aliases: [],
|
|
23647
|
+
usage: command.name,
|
|
23648
|
+
summary: command.summary,
|
|
23649
|
+
source: "internal"
|
|
23650
|
+
}));
|
|
23651
|
+
return {
|
|
23652
|
+
commands: operations2.map((operation) => operation.name),
|
|
23653
|
+
operations: operations2,
|
|
23654
|
+
helpText: internalRuntime.helpText ?? buildInternalHelpText(name, internalRuntime.commands),
|
|
23655
|
+
hasCli: true
|
|
23656
|
+
};
|
|
23657
|
+
}
|
|
23658
|
+
const cliPath = getConnectorCliPath(name);
|
|
23659
|
+
if (!cliPath) {
|
|
23660
|
+
return { commands: [], operations: [], helpText: "", hasCli: false };
|
|
23661
|
+
}
|
|
23662
|
+
const result = await runConnectorCommand2(name, ["--help"]);
|
|
23663
|
+
const helpText = result.stdout || result.stderr;
|
|
23664
|
+
const operations = parseCommanderHelpOperations(helpText);
|
|
23665
|
+
return {
|
|
23666
|
+
commands: operations.map((operation) => operation.name),
|
|
23667
|
+
operations,
|
|
23668
|
+
helpText,
|
|
23669
|
+
hasCli: true
|
|
23670
|
+
};
|
|
23671
|
+
}
|
|
23672
|
+
async function getConnectorCommandHelp(name, command) {
|
|
23673
|
+
const internalRuntime = getInternalCommandRuntime(name);
|
|
23674
|
+
if (internalRuntime?.getHelp) {
|
|
23675
|
+
const help = await internalRuntime.getHelp(command);
|
|
23676
|
+
if (help) {
|
|
23677
|
+
return help;
|
|
23678
|
+
}
|
|
23679
|
+
}
|
|
23680
|
+
const runtimeCommand = internalRuntime?.commands.find((runtimeEntry) => runtimeEntry.name === command);
|
|
23681
|
+
if (runtimeCommand?.helpText) {
|
|
23682
|
+
return runtimeCommand.helpText;
|
|
23683
|
+
}
|
|
23684
|
+
const result = await runConnectorCommand2(name, [command, "--help"]);
|
|
23685
|
+
return result.stdout || result.stderr;
|
|
23686
|
+
}
|
|
23687
|
+
|
|
23688
|
+
// src/server/auth.ts
|
|
23689
|
+
import { existsSync as existsSync14, readFileSync as readFileSync6, writeFileSync as writeFileSync5, mkdirSync as mkdirSync9, readdirSync as readdirSync8, rmSync as rmSync3, statSync as statSync5 } from "fs";
|
|
23690
|
+
import { randomBytes } from "crypto";
|
|
23691
|
+
import { join as join15 } from "path";
|
|
23692
|
+
|
|
23693
|
+
// src/lib/lock.ts
|
|
23694
|
+
init_database();
|
|
23695
|
+
import { openSync, closeSync, unlinkSync, existsSync as existsSync13, statSync as statSync4 } from "fs";
|
|
23696
|
+
import { join as join14 } from "path";
|
|
23697
|
+
import { mkdirSync as mkdirSync8 } from "fs";
|
|
23698
|
+
var LOCK_TIMEOUT_MS = 5000;
|
|
23699
|
+
var LOCK_RETRY_MS = 100;
|
|
23700
|
+
var STALE_LOCK_MS = 30000;
|
|
23701
|
+
|
|
23702
|
+
class LockTimeoutError extends Error {
|
|
23703
|
+
connector;
|
|
23704
|
+
constructor(connector) {
|
|
24433
23705
|
super(`Could not acquire write lock for connector "${connector}" within ${LOCK_TIMEOUT_MS}ms. Another agent may be writing. Try again shortly.`);
|
|
24434
23706
|
this.connector = connector;
|
|
24435
23707
|
this.name = "LockTimeoutError";
|
|
24436
23708
|
}
|
|
24437
23709
|
}
|
|
24438
23710
|
function lockPath(connector) {
|
|
24439
|
-
const dir =
|
|
24440
|
-
|
|
24441
|
-
return
|
|
23711
|
+
const dir = join14(getConnectorsHome(), `connect-${connector}`);
|
|
23712
|
+
mkdirSync8(dir, { recursive: true });
|
|
23713
|
+
return join14(dir, ".write.lock");
|
|
24442
23714
|
}
|
|
24443
23715
|
function isStale(path) {
|
|
24444
23716
|
try {
|
|
24445
|
-
const stat =
|
|
23717
|
+
const stat = statSync4(path);
|
|
24446
23718
|
return Date.now() - stat.mtimeMs > STALE_LOCK_MS;
|
|
24447
23719
|
} catch {
|
|
24448
23720
|
return false;
|
|
24449
23721
|
}
|
|
24450
23722
|
}
|
|
24451
23723
|
function tryAcquire(path) {
|
|
24452
|
-
if (
|
|
23724
|
+
if (existsSync13(path) && isStale(path)) {
|
|
24453
23725
|
try {
|
|
24454
23726
|
unlinkSync(path);
|
|
24455
23727
|
} catch {}
|
|
@@ -24470,7 +23742,6 @@ function release(path) {
|
|
|
24470
23742
|
} catch {}
|
|
24471
23743
|
}
|
|
24472
23744
|
async function withWriteLock(connector, fn) {
|
|
24473
|
-
connector = normalizeConnectorName(connector);
|
|
24474
23745
|
const path = lockPath(connector);
|
|
24475
23746
|
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
24476
23747
|
while (Date.now() < deadline) {
|
|
@@ -24487,6 +23758,7 @@ async function withWriteLock(connector, fn) {
|
|
|
24487
23758
|
}
|
|
24488
23759
|
|
|
24489
23760
|
// src/server/auth.ts
|
|
23761
|
+
init_database();
|
|
24490
23762
|
var FETCH_TIMEOUT = 1e4;
|
|
24491
23763
|
var oauthStateStore = new Map;
|
|
24492
23764
|
var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
@@ -24530,7 +23802,6 @@ var GOOGLE_SCOPES = {
|
|
|
24530
23802
|
].join(" ")
|
|
24531
23803
|
};
|
|
24532
23804
|
function getAuthType(name) {
|
|
24533
|
-
name = normalizeConnectorName(name);
|
|
24534
23805
|
const docs = getConnectorDocs(name);
|
|
24535
23806
|
if (!docs?.auth)
|
|
24536
23807
|
return "apikey";
|
|
@@ -24541,65 +23812,53 @@ function getAuthType(name) {
|
|
|
24541
23812
|
return "bearer";
|
|
24542
23813
|
return "apikey";
|
|
24543
23814
|
}
|
|
24544
|
-
function
|
|
24545
|
-
|
|
24546
|
-
return
|
|
24547
|
-
}
|
|
24548
|
-
function getConnectorConfigReadDirs2(name) {
|
|
24549
|
-
name = normalizeConnectorName(name);
|
|
24550
|
-
return getConnectorConfigReadDirs(name);
|
|
23815
|
+
function getConnectorConfigDir(name) {
|
|
23816
|
+
const connectorName = name.startsWith("connect-") ? name : `connect-${name}`;
|
|
23817
|
+
return join15(getConnectorsHome(), connectorName);
|
|
24551
23818
|
}
|
|
24552
23819
|
function getCurrentProfile2(name) {
|
|
24553
|
-
|
|
24554
|
-
|
|
24555
|
-
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
24559
|
-
|
|
24560
|
-
return "default";
|
|
24561
|
-
}
|
|
23820
|
+
const configDir = getConnectorConfigDir(name);
|
|
23821
|
+
const currentProfileFile = join15(configDir, "current_profile");
|
|
23822
|
+
if (existsSync14(currentProfileFile)) {
|
|
23823
|
+
try {
|
|
23824
|
+
return readFileSync6(currentProfileFile, "utf-8").trim() || "default";
|
|
23825
|
+
} catch {
|
|
23826
|
+
return "default";
|
|
24562
23827
|
}
|
|
24563
23828
|
}
|
|
24564
23829
|
return "default";
|
|
24565
23830
|
}
|
|
24566
|
-
function
|
|
23831
|
+
function loadProfileConfig(name) {
|
|
23832
|
+
const configDir = getConnectorConfigDir(name);
|
|
23833
|
+
const profile = getCurrentProfile2(name);
|
|
24567
23834
|
let flatConfig = {};
|
|
24568
23835
|
let dirConfig = {};
|
|
24569
|
-
const profileFile =
|
|
24570
|
-
if (
|
|
23836
|
+
const profileFile = join15(configDir, "profiles", `${profile}.json`);
|
|
23837
|
+
if (existsSync14(profileFile)) {
|
|
24571
23838
|
try {
|
|
24572
|
-
flatConfig = JSON.parse(
|
|
23839
|
+
flatConfig = JSON.parse(readFileSync6(profileFile, "utf-8"));
|
|
24573
23840
|
} catch {}
|
|
24574
23841
|
}
|
|
24575
|
-
const profileDirConfig =
|
|
24576
|
-
if (
|
|
23842
|
+
const profileDirConfig = join15(configDir, "profiles", profile, "config.json");
|
|
23843
|
+
if (existsSync14(profileDirConfig)) {
|
|
24577
23844
|
try {
|
|
24578
|
-
dirConfig = JSON.parse(
|
|
23845
|
+
dirConfig = JSON.parse(readFileSync6(profileDirConfig, "utf-8"));
|
|
24579
23846
|
} catch {}
|
|
24580
23847
|
}
|
|
24581
|
-
|
|
24582
|
-
}
|
|
24583
|
-
function loadProfileConfig(name) {
|
|
24584
|
-
name = normalizeConnectorName(name);
|
|
24585
|
-
const profile = getCurrentProfile2(name);
|
|
24586
|
-
const merged = {};
|
|
24587
|
-
for (const configDir of [...getConnectorConfigReadDirs2(name)].reverse()) {
|
|
24588
|
-
Object.assign(merged, loadProfileConfigFromDir(configDir, profile));
|
|
23848
|
+
if (Object.keys(flatConfig).length === 0 && Object.keys(dirConfig).length === 0) {
|
|
23849
|
+
return {};
|
|
24589
23850
|
}
|
|
24590
|
-
return
|
|
23851
|
+
return { ...flatConfig, ...dirConfig };
|
|
24591
23852
|
}
|
|
24592
|
-
function
|
|
24593
|
-
|
|
23853
|
+
function loadTokens(name) {
|
|
23854
|
+
const configDir = getConnectorConfigDir(name);
|
|
24594
23855
|
const profile = getCurrentProfile2(name);
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24598
|
-
|
|
24599
|
-
|
|
24600
|
-
|
|
24601
|
-
return null;
|
|
24602
|
-
}
|
|
23856
|
+
const tokensFile = join15(configDir, "profiles", profile, "tokens.json");
|
|
23857
|
+
if (existsSync14(tokensFile)) {
|
|
23858
|
+
try {
|
|
23859
|
+
return JSON.parse(readFileSync6(tokensFile, "utf-8"));
|
|
23860
|
+
} catch {
|
|
23861
|
+
return null;
|
|
24603
23862
|
}
|
|
24604
23863
|
}
|
|
24605
23864
|
const profileConfig = loadProfileConfig(name);
|
|
@@ -24614,50 +23873,28 @@ function loadTokens3(name) {
|
|
|
24614
23873
|
}
|
|
24615
23874
|
return null;
|
|
24616
23875
|
}
|
|
24617
|
-
function isStoredOAuthEnvVarSet(variable, oauthConfig, tokens, profileConfig) {
|
|
24618
|
-
if (variable.endsWith("_CLIENT_ID")) {
|
|
24619
|
-
return Boolean(oauthConfig.clientId || profileConfig.clientId);
|
|
24620
|
-
}
|
|
24621
|
-
if (variable.endsWith("_CLIENT_SECRET")) {
|
|
24622
|
-
return Boolean(oauthConfig.clientSecret || profileConfig.clientSecret);
|
|
24623
|
-
}
|
|
24624
|
-
if (variable.endsWith("_ACCESS_TOKEN")) {
|
|
24625
|
-
return Boolean(tokens?.accessToken || profileConfig.accessToken);
|
|
24626
|
-
}
|
|
24627
|
-
if (variable.endsWith("_REFRESH_TOKEN")) {
|
|
24628
|
-
return Boolean(tokens?.refreshToken || profileConfig.refreshToken);
|
|
24629
|
-
}
|
|
24630
|
-
if (variable.endsWith("_TOKEN_EXPIRES_AT")) {
|
|
24631
|
-
return Boolean(tokens?.expiresAt || profileConfig.expiresAt);
|
|
24632
|
-
}
|
|
24633
|
-
return false;
|
|
24634
|
-
}
|
|
24635
23876
|
function getAuthStatus(name) {
|
|
24636
|
-
name = normalizeConnectorName(name);
|
|
24637
23877
|
const authType = getAuthType(name);
|
|
24638
23878
|
const docs = getConnectorDocs(name);
|
|
24639
|
-
const oauthConfig = authType === "oauth" ? getOAuthConfig(name) : {};
|
|
24640
|
-
const tokens = authType === "oauth" ? loadTokens3(name) : null;
|
|
24641
|
-
const profileConfig = authType === "oauth" ? loadProfileConfig(name) : {};
|
|
24642
23879
|
const envVars = (docs?.envVars || []).map((v) => ({
|
|
24643
23880
|
variable: v.variable,
|
|
24644
23881
|
description: v.description,
|
|
24645
|
-
set: !!process.env[v.variable]
|
|
23882
|
+
set: !!process.env[v.variable]
|
|
24646
23883
|
}));
|
|
24647
23884
|
const envVarTotalCount = envVars.length;
|
|
24648
23885
|
const envVarSetCount = envVars.filter((v) => v.set).length;
|
|
24649
23886
|
if (authType === "oauth") {
|
|
24650
|
-
const
|
|
24651
|
-
const
|
|
24652
|
-
const
|
|
24653
|
-
const
|
|
23887
|
+
const tokens = loadTokens(name);
|
|
23888
|
+
const config2 = loadProfileConfig(name);
|
|
23889
|
+
const hasTokens = !!tokens?.accessToken || !!config2.accessToken;
|
|
23890
|
+
const hasRefreshToken = !!tokens?.refreshToken || !!config2.refreshToken;
|
|
23891
|
+
const tokenExpiry = tokens?.expiresAt || config2.expiresAt;
|
|
24654
23892
|
const hasEnvVar2 = envVars.some((v) => v.set);
|
|
24655
23893
|
return {
|
|
24656
23894
|
type: "oauth",
|
|
24657
|
-
configured: hasTokens || hasRefreshToken ||
|
|
23895
|
+
configured: hasTokens || hasRefreshToken || hasEnvVar2,
|
|
24658
23896
|
tokenExpiry,
|
|
24659
23897
|
hasRefreshToken,
|
|
24660
|
-
hasOAuthCredentials,
|
|
24661
23898
|
envVars,
|
|
24662
23899
|
envVarSetCount,
|
|
24663
23900
|
envVarTotalCount
|
|
@@ -24674,686 +23911,241 @@ function getAuthStatus(name) {
|
|
|
24674
23911
|
envVarTotalCount
|
|
24675
23912
|
};
|
|
24676
23913
|
}
|
|
24677
|
-
function getEnvVars(name) {
|
|
24678
|
-
name = normalizeConnectorName(name);
|
|
24679
|
-
const docs = getConnectorDocs(name);
|
|
24680
|
-
return docs?.envVars || [];
|
|
24681
|
-
}
|
|
24682
23914
|
async function saveApiKey(name, key, field) {
|
|
24683
|
-
name = normalizeConnectorName(name);
|
|
24684
23915
|
return withWriteLock(name, () => _saveApiKey(name, key, field));
|
|
24685
23916
|
}
|
|
24686
23917
|
function _saveApiKey(name, key, field) {
|
|
24687
|
-
|
|
24688
|
-
const configDir = getConnectorConfigDir2(name);
|
|
23918
|
+
const configDir = getConnectorConfigDir(name);
|
|
24689
23919
|
const profile = getCurrentProfile2(name);
|
|
24690
23920
|
const keyField = field || guessKeyField(name);
|
|
24691
23921
|
if (keyField === "clientId" || keyField === "clientSecret") {
|
|
24692
|
-
const credentialsFile =
|
|
24693
|
-
|
|
23922
|
+
const credentialsFile = join15(configDir, "credentials.json");
|
|
23923
|
+
mkdirSync9(configDir, { recursive: true });
|
|
24694
23924
|
let creds = {};
|
|
24695
|
-
if (
|
|
23925
|
+
if (existsSync14(credentialsFile)) {
|
|
24696
23926
|
try {
|
|
24697
|
-
creds = JSON.parse(
|
|
23927
|
+
creds = JSON.parse(readFileSync6(credentialsFile, "utf-8"));
|
|
24698
23928
|
} catch {}
|
|
24699
23929
|
}
|
|
24700
23930
|
creds[keyField] = key;
|
|
24701
|
-
|
|
24702
|
-
return;
|
|
24703
|
-
}
|
|
24704
|
-
const profileFile = join16(configDir, "profiles", `${profile}.json`);
|
|
24705
|
-
const profileDir = join16(configDir, "profiles", profile);
|
|
24706
|
-
if (existsSync16(profileFile)) {
|
|
24707
|
-
let config = {};
|
|
24708
|
-
try {
|
|
24709
|
-
config = JSON.parse(readFileSync8(profileFile, "utf-8"));
|
|
24710
|
-
} catch {}
|
|
24711
|
-
config[keyField] = key;
|
|
24712
|
-
writeFileSync7(profileFile, JSON.stringify(config, null, 2));
|
|
24713
|
-
return;
|
|
24714
|
-
}
|
|
24715
|
-
if (existsSync16(profileDir)) {
|
|
24716
|
-
const configFile = join16(profileDir, "config.json");
|
|
24717
|
-
let config = {};
|
|
24718
|
-
if (existsSync16(configFile)) {
|
|
24719
|
-
try {
|
|
24720
|
-
config = JSON.parse(readFileSync8(configFile, "utf-8"));
|
|
24721
|
-
} catch {}
|
|
24722
|
-
}
|
|
24723
|
-
config[keyField] = key;
|
|
24724
|
-
writeFileSync7(configFile, JSON.stringify(config, null, 2));
|
|
24725
|
-
return;
|
|
24726
|
-
}
|
|
24727
|
-
mkdirSync11(profileDir, { recursive: true });
|
|
24728
|
-
writeFileSync7(join16(profileDir, "config.json"), JSON.stringify({ [keyField]: key }, null, 2));
|
|
24729
|
-
}
|
|
24730
|
-
function guessKeyField(name) {
|
|
24731
|
-
name = normalizeConnectorName(name);
|
|
24732
|
-
const docs = getConnectorDocs(name);
|
|
24733
|
-
if (!docs?.envVars.length)
|
|
24734
|
-
return "apiKey";
|
|
24735
|
-
const keyVar = docs.envVars.find((v) => v.variable.includes("API_KEY") || v.variable.includes("API_SECRET") || v.variable.includes("TOKEN") || v.variable.includes("SECRET"));
|
|
24736
|
-
if (keyVar) {
|
|
24737
|
-
const parts = keyVar.variable.toLowerCase().split("_");
|
|
24738
|
-
const withoutPrefix = parts.slice(1);
|
|
24739
|
-
if (withoutPrefix.length > 0) {
|
|
24740
|
-
return withoutPrefix.map((p, i) => i === 0 ? p : p.charAt(0).toUpperCase() + p.slice(1)).join("");
|
|
24741
|
-
}
|
|
24742
|
-
}
|
|
24743
|
-
return "apiKey";
|
|
24744
|
-
}
|
|
24745
|
-
function getOAuthConfig(name) {
|
|
24746
|
-
name = normalizeConnectorName(name);
|
|
24747
|
-
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
24748
|
-
const credentialsFile = join16(configDir, "credentials.json");
|
|
24749
|
-
if (existsSync16(credentialsFile)) {
|
|
24750
|
-
try {
|
|
24751
|
-
const creds = JSON.parse(readFileSync8(credentialsFile, "utf-8"));
|
|
24752
|
-
return { clientId: creds.clientId, clientSecret: creds.clientSecret };
|
|
24753
|
-
} catch {}
|
|
24754
|
-
}
|
|
24755
|
-
}
|
|
24756
|
-
const config = loadProfileConfig(name);
|
|
24757
|
-
return {
|
|
24758
|
-
clientId: config.clientId,
|
|
24759
|
-
clientSecret: config.clientSecret
|
|
24760
|
-
};
|
|
24761
|
-
}
|
|
24762
|
-
function getOAuthStartUrl(name, redirectUri) {
|
|
24763
|
-
name = normalizeConnectorName(name);
|
|
24764
|
-
const oauthConfig = getOAuthConfig(name);
|
|
24765
|
-
if (!oauthConfig.clientId)
|
|
24766
|
-
return null;
|
|
24767
|
-
const scopes = GOOGLE_SCOPES[name];
|
|
24768
|
-
if (!scopes)
|
|
24769
|
-
return null;
|
|
24770
|
-
const state = randomBytes(32).toString("hex");
|
|
24771
|
-
oauthStateStore.set(state, { connector: name, createdAt: Date.now() });
|
|
24772
|
-
const tenMinutesAgo = Date.now() - 10 * 60 * 1000;
|
|
24773
|
-
for (const [key, val] of oauthStateStore) {
|
|
24774
|
-
if (val.createdAt < tenMinutesAgo)
|
|
24775
|
-
oauthStateStore.delete(key);
|
|
24776
|
-
}
|
|
24777
|
-
const params = new URLSearchParams({
|
|
24778
|
-
client_id: oauthConfig.clientId,
|
|
24779
|
-
redirect_uri: redirectUri,
|
|
24780
|
-
response_type: "code",
|
|
24781
|
-
scope: scopes,
|
|
24782
|
-
access_type: "offline",
|
|
24783
|
-
prompt: "consent",
|
|
24784
|
-
state
|
|
24785
|
-
});
|
|
24786
|
-
return `${GOOGLE_AUTH_URL}?${params.toString()}`;
|
|
24787
|
-
}
|
|
24788
|
-
function validateOAuthState(state, expectedConnector) {
|
|
24789
|
-
expectedConnector = normalizeConnectorName(expectedConnector);
|
|
24790
|
-
if (!state)
|
|
24791
|
-
return false;
|
|
24792
|
-
const entry = oauthStateStore.get(state);
|
|
24793
|
-
if (!entry || entry.connector !== expectedConnector)
|
|
24794
|
-
return false;
|
|
24795
|
-
oauthStateStore.delete(state);
|
|
24796
|
-
return Date.now() - entry.createdAt < 10 * 60 * 1000;
|
|
24797
|
-
}
|
|
24798
|
-
async function exchangeOAuthCode(name, code, redirectUri) {
|
|
24799
|
-
name = normalizeConnectorName(name);
|
|
24800
|
-
const oauthConfig = getOAuthConfig(name);
|
|
24801
|
-
if (!oauthConfig.clientId || !oauthConfig.clientSecret) {
|
|
24802
|
-
throw new Error("OAuth credentials not configured for " + name);
|
|
24803
|
-
}
|
|
24804
|
-
const response = await fetch(GOOGLE_TOKEN_URL, {
|
|
24805
|
-
method: "POST",
|
|
24806
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
24807
|
-
body: new URLSearchParams({
|
|
24808
|
-
code,
|
|
24809
|
-
client_id: oauthConfig.clientId,
|
|
24810
|
-
client_secret: oauthConfig.clientSecret,
|
|
24811
|
-
redirect_uri: redirectUri,
|
|
24812
|
-
grant_type: "authorization_code"
|
|
24813
|
-
}),
|
|
24814
|
-
signal: AbortSignal.timeout(FETCH_TIMEOUT)
|
|
24815
|
-
});
|
|
24816
|
-
if (!response.ok) {
|
|
24817
|
-
const error = await response.json().catch(() => ({ error: response.statusText }));
|
|
24818
|
-
throw new Error(`Token exchange failed: ${error.error_description || error.error || response.statusText}`);
|
|
24819
|
-
}
|
|
24820
|
-
const data = await response.json();
|
|
24821
|
-
const tokens = {
|
|
24822
|
-
accessToken: data.access_token,
|
|
24823
|
-
refreshToken: data.refresh_token,
|
|
24824
|
-
expiresAt: Date.now() + data.expires_in * 1000,
|
|
24825
|
-
tokenType: data.token_type,
|
|
24826
|
-
scope: data.scope
|
|
24827
|
-
};
|
|
24828
|
-
saveOAuthTokens(name, tokens);
|
|
24829
|
-
return tokens;
|
|
24830
|
-
}
|
|
24831
|
-
function saveOAuthTokens(name, tokens) {
|
|
24832
|
-
name = normalizeConnectorName(name);
|
|
24833
|
-
const configDir = getConnectorConfigDir2(name);
|
|
24834
|
-
const profile = getCurrentProfile2(name);
|
|
24835
|
-
const profileDir = join16(configDir, "profiles", profile);
|
|
24836
|
-
mkdirSync11(profileDir, { recursive: true });
|
|
24837
|
-
const tokensFile = join16(profileDir, "tokens.json");
|
|
24838
|
-
writeFileSync7(tokensFile, JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
24839
|
-
}
|
|
24840
|
-
async function refreshOAuthToken(name) {
|
|
24841
|
-
name = normalizeConnectorName(name);
|
|
24842
|
-
return withWriteLock(name, () => _refreshOAuthToken(name));
|
|
24843
|
-
}
|
|
24844
|
-
async function _refreshOAuthToken(name) {
|
|
24845
|
-
name = normalizeConnectorName(name);
|
|
24846
|
-
const oauthConfig = getOAuthConfig(name);
|
|
24847
|
-
const currentTokens = loadTokens3(name);
|
|
24848
|
-
if (!oauthConfig.clientId || !oauthConfig.clientSecret) {
|
|
24849
|
-
throw new Error("OAuth credentials not configured for " + name);
|
|
24850
|
-
}
|
|
24851
|
-
if (!currentTokens?.refreshToken) {
|
|
24852
|
-
throw new Error("No refresh token available. Please re-authenticate.");
|
|
24853
|
-
}
|
|
24854
|
-
const response = await fetch(GOOGLE_TOKEN_URL, {
|
|
24855
|
-
method: "POST",
|
|
24856
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
24857
|
-
body: new URLSearchParams({
|
|
24858
|
-
client_id: oauthConfig.clientId,
|
|
24859
|
-
client_secret: oauthConfig.clientSecret,
|
|
24860
|
-
refresh_token: currentTokens.refreshToken,
|
|
24861
|
-
grant_type: "refresh_token"
|
|
24862
|
-
}),
|
|
24863
|
-
signal: AbortSignal.timeout(FETCH_TIMEOUT)
|
|
24864
|
-
});
|
|
24865
|
-
if (!response.ok) {
|
|
24866
|
-
const error = await response.json().catch(() => ({ error: response.statusText }));
|
|
24867
|
-
throw new Error(`Token refresh failed: ${error.error_description || error.error}`);
|
|
24868
|
-
}
|
|
24869
|
-
const data = await response.json();
|
|
24870
|
-
const tokens = {
|
|
24871
|
-
accessToken: data.access_token,
|
|
24872
|
-
refreshToken: currentTokens.refreshToken,
|
|
24873
|
-
expiresAt: Date.now() + data.expires_in * 1000,
|
|
24874
|
-
tokenType: data.token_type,
|
|
24875
|
-
scope: data.scope || currentTokens.scope
|
|
24876
|
-
};
|
|
24877
|
-
saveOAuthTokens(name, tokens);
|
|
24878
|
-
return tokens;
|
|
24879
|
-
}
|
|
24880
|
-
function listProfiles4(name) {
|
|
24881
|
-
name = normalizeConnectorName(name);
|
|
24882
|
-
const seen = new Set;
|
|
24883
|
-
for (const configDir of getConnectorConfigReadDirs2(name)) {
|
|
24884
|
-
const profilesDir = join16(configDir, "profiles");
|
|
24885
|
-
if (!existsSync16(profilesDir))
|
|
24886
|
-
continue;
|
|
24887
|
-
try {
|
|
24888
|
-
const entries = readdirSync10(profilesDir);
|
|
24889
|
-
for (const entry of entries) {
|
|
24890
|
-
const fullPath = join16(profilesDir, entry);
|
|
24891
|
-
const stat = statSync6(fullPath);
|
|
24892
|
-
if (stat.isDirectory()) {
|
|
24893
|
-
seen.add(entry);
|
|
24894
|
-
} else if (entry.endsWith(".json")) {
|
|
24895
|
-
seen.add(entry.replace(/\.json$/, ""));
|
|
24896
|
-
}
|
|
24897
|
-
}
|
|
24898
|
-
} catch {}
|
|
24899
|
-
}
|
|
24900
|
-
seen.add("default");
|
|
24901
|
-
return Array.from(seen).sort();
|
|
24902
|
-
}
|
|
24903
|
-
function switchProfile(name, profile) {
|
|
24904
|
-
name = normalizeConnectorName(name);
|
|
24905
|
-
const configDir = getConnectorConfigDir2(name);
|
|
24906
|
-
mkdirSync11(configDir, { recursive: true });
|
|
24907
|
-
writeFileSync7(join16(configDir, "current_profile"), profile);
|
|
24908
|
-
}
|
|
24909
|
-
function deleteProfile2(name, profile) {
|
|
24910
|
-
name = normalizeConnectorName(name);
|
|
24911
|
-
if (profile === "default")
|
|
24912
|
-
return false;
|
|
24913
|
-
const configDir = getConnectorConfigDir2(name);
|
|
24914
|
-
const profilesDir = join16(configDir, "profiles");
|
|
24915
|
-
const profileFile = join16(profilesDir, `${profile}.json`);
|
|
24916
|
-
if (existsSync16(profileFile)) {
|
|
24917
|
-
rmSync3(profileFile);
|
|
24918
|
-
if (getCurrentProfile2(name) === profile) {
|
|
24919
|
-
switchProfile(name, "default");
|
|
24920
|
-
}
|
|
24921
|
-
return true;
|
|
24922
|
-
}
|
|
24923
|
-
const profileDir = join16(profilesDir, profile);
|
|
24924
|
-
if (existsSync16(profileDir)) {
|
|
24925
|
-
rmSync3(profileDir, { recursive: true });
|
|
24926
|
-
if (getCurrentProfile2(name) === profile) {
|
|
24927
|
-
switchProfile(name, "default");
|
|
24928
|
-
}
|
|
24929
|
-
return true;
|
|
24930
|
-
}
|
|
24931
|
-
return false;
|
|
24932
|
-
}
|
|
24933
|
-
|
|
24934
|
-
// src/lib/runner.ts
|
|
24935
|
-
var __dirname5 = dirname7(fileURLToPath5(import.meta.url));
|
|
24936
|
-
function resolveConnectorsDir2() {
|
|
24937
|
-
const fromBin = join17(__dirname5, "..", "connectors");
|
|
24938
|
-
if (existsSync17(fromBin))
|
|
24939
|
-
return fromBin;
|
|
24940
|
-
const fromSrc = join17(__dirname5, "..", "..", "connectors");
|
|
24941
|
-
if (existsSync17(fromSrc))
|
|
24942
|
-
return fromSrc;
|
|
24943
|
-
return fromBin;
|
|
24944
|
-
}
|
|
24945
|
-
var CONNECTORS_DIR2 = resolveConnectorsDir2();
|
|
24946
|
-
function buildInternalHelpText(name, commands) {
|
|
24947
|
-
const lines = [
|
|
24948
|
-
`Usage: connect-${name} [options] [command]`,
|
|
24949
|
-
"",
|
|
24950
|
-
"Commands:"
|
|
24951
|
-
];
|
|
24952
|
-
for (const command of commands) {
|
|
24953
|
-
lines.push(` ${command.name.padEnd(24)} ${command.summary}`);
|
|
24954
|
-
}
|
|
24955
|
-
return lines.join(`
|
|
24956
|
-
`);
|
|
24957
|
-
}
|
|
24958
|
-
function getInternalCommandRuntime(name) {
|
|
24959
|
-
return getInternalConnectorDefinition(name)?.commandRuntime;
|
|
24960
|
-
}
|
|
24961
|
-
var ENV_VAR_NAME_OVERRIDES = {
|
|
24962
|
-
googlemaps: ["GOOGLE_MAPS"],
|
|
24963
|
-
googletasks: ["GOOGLE_TASKS", "GOOGLE"],
|
|
24964
|
-
google: ["GOOGLE"],
|
|
24965
|
-
stabilityai: ["STABILITY"],
|
|
24966
|
-
openweathermap: ["OPENWEATHERMAP", "OPENWEATHER"]
|
|
24967
|
-
};
|
|
24968
|
-
function buildEnvWithCredentials(connectorName, baseEnv) {
|
|
24969
|
-
const env = { ...baseEnv };
|
|
24970
|
-
const normalizedConnectorName = normalizeConnectorName(connectorName);
|
|
24971
|
-
const prefixes = ENV_VAR_NAME_OVERRIDES[normalizedConnectorName] || [
|
|
24972
|
-
normalizedConnectorName.toUpperCase().replace(/-/g, "_")
|
|
24973
|
-
];
|
|
24974
|
-
for (const prefix of prefixes) {
|
|
24975
|
-
const canonicalKey = `${prefix}_API_KEY`;
|
|
24976
|
-
if (env[canonicalKey])
|
|
24977
|
-
continue;
|
|
24978
|
-
const alternatives = [
|
|
24979
|
-
`HASNAXYZ_${prefix}_LIVE_API_KEY`,
|
|
24980
|
-
`HASNA_${prefix}_LIVE_API_KEY`,
|
|
24981
|
-
`${prefix}_LIVE_API_KEY`,
|
|
24982
|
-
`${prefix}_KEY`,
|
|
24983
|
-
`${prefix}_TOKEN`
|
|
24984
|
-
];
|
|
24985
|
-
for (const alt of alternatives) {
|
|
24986
|
-
const value = env[alt];
|
|
24987
|
-
if (value) {
|
|
24988
|
-
env[canonicalKey] = value;
|
|
24989
|
-
break;
|
|
24990
|
-
}
|
|
24991
|
-
}
|
|
24992
|
-
}
|
|
24993
|
-
if (getAuthType(normalizedConnectorName) === "oauth") {
|
|
24994
|
-
const oauthConfig = getOAuthConfig(normalizedConnectorName);
|
|
24995
|
-
const tokens = loadTokens3(normalizedConnectorName);
|
|
24996
|
-
for (const { variable } of getEnvVars(normalizedConnectorName)) {
|
|
24997
|
-
if (env[variable])
|
|
24998
|
-
continue;
|
|
24999
|
-
if (variable.endsWith("_CLIENT_ID") && oauthConfig.clientId) {
|
|
25000
|
-
env[variable] = oauthConfig.clientId;
|
|
25001
|
-
} else if (variable.endsWith("_CLIENT_SECRET") && oauthConfig.clientSecret) {
|
|
25002
|
-
env[variable] = oauthConfig.clientSecret;
|
|
25003
|
-
} else if (variable.endsWith("_ACCESS_TOKEN") && tokens?.accessToken) {
|
|
25004
|
-
env[variable] = tokens.accessToken;
|
|
25005
|
-
} else if (variable.endsWith("_REFRESH_TOKEN") && tokens?.refreshToken) {
|
|
25006
|
-
env[variable] = tokens.refreshToken;
|
|
25007
|
-
} else if (variable.endsWith("_TOKEN_EXPIRES_AT") && tokens?.expiresAt) {
|
|
25008
|
-
env[variable] = String(tokens.expiresAt);
|
|
25009
|
-
}
|
|
25010
|
-
}
|
|
25011
|
-
}
|
|
25012
|
-
return env;
|
|
25013
|
-
}
|
|
25014
|
-
function getConnectorCliPath(name) {
|
|
25015
|
-
const safeName = normalizeConnectorName(name).replace(/[^a-z0-9-]/g, "");
|
|
25016
|
-
const connectorDir = getConnectorPackagePath(CONNECTORS_DIR2, safeName);
|
|
25017
|
-
const cliPath = join17(connectorDir, "src", "cli", "index.ts");
|
|
25018
|
-
if (existsSync17(cliPath))
|
|
25019
|
-
return cliPath;
|
|
25020
|
-
return null;
|
|
25021
|
-
}
|
|
25022
|
-
function hasConnectorCommandSurface(name) {
|
|
25023
|
-
return Boolean(getInternalCommandRuntime(name)?.commands.length || getConnectorCliPath(name));
|
|
25024
|
-
}
|
|
25025
|
-
function normalizeCommanderUsage(usage) {
|
|
25026
|
-
const commandToken = usage.trim().split(/\s+/)[0];
|
|
25027
|
-
if (!commandToken || commandToken === "help")
|
|
25028
|
-
return null;
|
|
25029
|
-
const aliases = commandToken.split("|").filter(Boolean);
|
|
25030
|
-
const [name, ...rest] = aliases;
|
|
25031
|
-
if (!name)
|
|
25032
|
-
return null;
|
|
25033
|
-
return {
|
|
25034
|
-
name,
|
|
25035
|
-
aliases: rest,
|
|
25036
|
-
usage: usage.trim()
|
|
25037
|
-
};
|
|
25038
|
-
}
|
|
25039
|
-
function parseCommanderHelpOperations(helpText) {
|
|
25040
|
-
const operations = [];
|
|
25041
|
-
const lines = helpText.split(`
|
|
25042
|
-
`);
|
|
25043
|
-
let inCommands = false;
|
|
25044
|
-
for (const line of lines) {
|
|
25045
|
-
if (line.trim().startsWith("Commands:")) {
|
|
25046
|
-
inCommands = true;
|
|
25047
|
-
continue;
|
|
25048
|
-
}
|
|
25049
|
-
if (!inCommands)
|
|
25050
|
-
continue;
|
|
25051
|
-
if (line.trim() === "") {
|
|
25052
|
-
if (operations.length > 0)
|
|
25053
|
-
inCommands = false;
|
|
25054
|
-
continue;
|
|
25055
|
-
}
|
|
25056
|
-
const row = line.match(/^ {2}(?! )(\S.*?)(?: {2,}(.+))?$/);
|
|
25057
|
-
if (!row)
|
|
25058
|
-
continue;
|
|
25059
|
-
const usage = row[1].trim();
|
|
25060
|
-
const summary = (row[2] ?? "").trim();
|
|
25061
|
-
const normalized = normalizeCommanderUsage(usage);
|
|
25062
|
-
if (!normalized)
|
|
25063
|
-
continue;
|
|
25064
|
-
operations.push({
|
|
25065
|
-
...normalized,
|
|
25066
|
-
summary,
|
|
25067
|
-
source: "cli"
|
|
25068
|
-
});
|
|
25069
|
-
}
|
|
25070
|
-
return operations;
|
|
25071
|
-
}
|
|
25072
|
-
function runConnectorCommand2(name, args, timeoutMs = 30000) {
|
|
25073
|
-
const connectorName = normalizeConnectorName(name);
|
|
25074
|
-
getConnectorsHome();
|
|
25075
|
-
const internalRuntime = getInternalCommandRuntime(connectorName);
|
|
25076
|
-
if (internalRuntime?.run) {
|
|
25077
|
-
return Promise.resolve(internalRuntime.run(args)).then((result) => {
|
|
25078
|
-
if (result) {
|
|
25079
|
-
const stdout = result.stdout.trim();
|
|
25080
|
-
const stderr = (result.stderr ?? "").trim();
|
|
25081
|
-
const exitCode = result.exitCode ?? (result.success === false ? 1 : 0);
|
|
25082
|
-
return {
|
|
25083
|
-
stdout,
|
|
25084
|
-
stderr,
|
|
25085
|
-
exitCode,
|
|
25086
|
-
success: result.success ?? exitCode === 0
|
|
25087
|
-
};
|
|
25088
|
-
}
|
|
25089
|
-
return runLegacyConnectorCommand(connectorName, args, timeoutMs);
|
|
25090
|
-
});
|
|
25091
|
-
}
|
|
25092
|
-
return runLegacyConnectorCommand(connectorName, args, timeoutMs);
|
|
25093
|
-
}
|
|
25094
|
-
async function runConnectorOperation(args) {
|
|
25095
|
-
const connectorName = normalizeConnectorName(args.connector);
|
|
25096
|
-
const internal = getInternalConnectorDefinition(connectorName);
|
|
25097
|
-
if (internal?.operations[args.operation]) {
|
|
25098
|
-
try {
|
|
25099
|
-
const operationData = await executeConnectorOperation(internal, {
|
|
25100
|
-
operation: args.operation,
|
|
25101
|
-
input: args.input,
|
|
25102
|
-
profile: args.profile
|
|
25103
|
-
});
|
|
25104
|
-
const commandResult = normalizeOperationReturn(operationData);
|
|
25105
|
-
return {
|
|
25106
|
-
connector: connectorName,
|
|
25107
|
-
operation: args.operation,
|
|
25108
|
-
profile: args.profile,
|
|
25109
|
-
...commandResult
|
|
25110
|
-
};
|
|
25111
|
-
} catch (error) {
|
|
25112
|
-
return {
|
|
25113
|
-
connector: connectorName,
|
|
25114
|
-
operation: args.operation,
|
|
25115
|
-
profile: args.profile,
|
|
25116
|
-
stdout: "",
|
|
25117
|
-
stderr: error.message,
|
|
25118
|
-
exitCode: 1,
|
|
25119
|
-
success: false
|
|
25120
|
-
};
|
|
25121
|
-
}
|
|
23931
|
+
writeFileSync5(credentialsFile, JSON.stringify(creds, null, 2));
|
|
23932
|
+
return;
|
|
25122
23933
|
}
|
|
25123
|
-
const
|
|
25124
|
-
const
|
|
25125
|
-
|
|
25126
|
-
|
|
25127
|
-
connector: connectorName,
|
|
25128
|
-
operation: args.operation,
|
|
25129
|
-
profile: args.profile
|
|
25130
|
-
};
|
|
25131
|
-
if (args.parseJson !== false && result.stdout) {
|
|
23934
|
+
const profileFile = join15(configDir, "profiles", `${profile}.json`);
|
|
23935
|
+
const profileDir = join15(configDir, "profiles", profile);
|
|
23936
|
+
if (existsSync14(profileFile)) {
|
|
23937
|
+
let config = {};
|
|
25132
23938
|
try {
|
|
25133
|
-
|
|
23939
|
+
config = JSON.parse(readFileSync6(profileFile, "utf-8"));
|
|
25134
23940
|
} catch {}
|
|
23941
|
+
config[keyField] = key;
|
|
23942
|
+
writeFileSync5(profileFile, JSON.stringify(config, null, 2));
|
|
23943
|
+
return;
|
|
25135
23944
|
}
|
|
25136
|
-
|
|
25137
|
-
|
|
25138
|
-
|
|
25139
|
-
|
|
25140
|
-
const result = value;
|
|
25141
|
-
const response = {
|
|
25142
|
-
...result
|
|
25143
|
-
};
|
|
25144
|
-
if (result.stdout) {
|
|
23945
|
+
if (existsSync14(profileDir)) {
|
|
23946
|
+
const configFile = join15(profileDir, "config.json");
|
|
23947
|
+
let config = {};
|
|
23948
|
+
if (existsSync14(configFile)) {
|
|
25145
23949
|
try {
|
|
25146
|
-
|
|
23950
|
+
config = JSON.parse(readFileSync6(configFile, "utf-8"));
|
|
25147
23951
|
} catch {}
|
|
25148
23952
|
}
|
|
25149
|
-
|
|
23953
|
+
config[keyField] = key;
|
|
23954
|
+
writeFileSync5(configFile, JSON.stringify(config, null, 2));
|
|
23955
|
+
return;
|
|
25150
23956
|
}
|
|
25151
|
-
|
|
25152
|
-
|
|
25153
|
-
stdout: JSON.stringify(value),
|
|
25154
|
-
stderr: "",
|
|
25155
|
-
exitCode: 0,
|
|
25156
|
-
success: true
|
|
25157
|
-
};
|
|
23957
|
+
mkdirSync9(profileDir, { recursive: true });
|
|
23958
|
+
writeFileSync5(join15(profileDir, "config.json"), JSON.stringify({ [keyField]: key }, null, 2));
|
|
25158
23959
|
}
|
|
25159
|
-
function
|
|
25160
|
-
|
|
25161
|
-
|
|
25162
|
-
|
|
25163
|
-
|
|
25164
|
-
|
|
25165
|
-
|
|
25166
|
-
|
|
25167
|
-
|
|
25168
|
-
|
|
25169
|
-
}
|
|
25170
|
-
commandArgs.push(...args.operation.split(".").filter(Boolean));
|
|
25171
|
-
for (const positional of args.input?.args ?? []) {
|
|
25172
|
-
commandArgs.push(String(positional));
|
|
25173
|
-
}
|
|
25174
|
-
let hasFormat = false;
|
|
25175
|
-
for (const [key, value] of Object.entries(args.input ?? {})) {
|
|
25176
|
-
if (key === "args")
|
|
25177
|
-
continue;
|
|
25178
|
-
if (value === undefined || value === null)
|
|
25179
|
-
continue;
|
|
25180
|
-
const flag = `--${key.replace(/_/g, "-").replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}`;
|
|
25181
|
-
if (flag === "--format" || flag === "--json")
|
|
25182
|
-
hasFormat = true;
|
|
25183
|
-
if (typeof value === "boolean") {
|
|
25184
|
-
if (value)
|
|
25185
|
-
commandArgs.push(flag);
|
|
25186
|
-
continue;
|
|
25187
|
-
}
|
|
25188
|
-
if (Array.isArray(value)) {
|
|
25189
|
-
for (const item of value) {
|
|
25190
|
-
commandArgs.push(flag, String(item));
|
|
25191
|
-
}
|
|
25192
|
-
continue;
|
|
23960
|
+
function guessKeyField(name) {
|
|
23961
|
+
const docs = getConnectorDocs(name);
|
|
23962
|
+
if (!docs?.envVars.length)
|
|
23963
|
+
return "apiKey";
|
|
23964
|
+
const keyVar = docs.envVars.find((v) => v.variable.includes("API_KEY") || v.variable.includes("API_SECRET") || v.variable.includes("TOKEN") || v.variable.includes("SECRET"));
|
|
23965
|
+
if (keyVar) {
|
|
23966
|
+
const parts = keyVar.variable.toLowerCase().split("_");
|
|
23967
|
+
const withoutPrefix = parts.slice(1);
|
|
23968
|
+
if (withoutPrefix.length > 0) {
|
|
23969
|
+
return withoutPrefix.map((p, i) => i === 0 ? p : p.charAt(0).toUpperCase() + p.slice(1)).join("");
|
|
25193
23970
|
}
|
|
25194
|
-
commandArgs.push(flag, String(value));
|
|
25195
23971
|
}
|
|
25196
|
-
|
|
25197
|
-
|
|
23972
|
+
return "apiKey";
|
|
23973
|
+
}
|
|
23974
|
+
function getOAuthConfig(name) {
|
|
23975
|
+
const configDir = getConnectorConfigDir(name);
|
|
23976
|
+
const credentialsFile = join15(configDir, "credentials.json");
|
|
23977
|
+
if (existsSync14(credentialsFile)) {
|
|
23978
|
+
try {
|
|
23979
|
+
const creds = JSON.parse(readFileSync6(credentialsFile, "utf-8"));
|
|
23980
|
+
return { clientId: creds.clientId, clientSecret: creds.clientSecret };
|
|
23981
|
+
} catch {}
|
|
25198
23982
|
}
|
|
25199
|
-
|
|
23983
|
+
const config = loadProfileConfig(name);
|
|
23984
|
+
return {
|
|
23985
|
+
clientId: config.clientId,
|
|
23986
|
+
clientSecret: config.clientSecret
|
|
23987
|
+
};
|
|
25200
23988
|
}
|
|
25201
|
-
function
|
|
25202
|
-
const
|
|
25203
|
-
|
|
25204
|
-
|
|
25205
|
-
|
|
25206
|
-
|
|
25207
|
-
|
|
25208
|
-
|
|
25209
|
-
|
|
25210
|
-
|
|
23989
|
+
function getOAuthStartUrl(name, redirectUri) {
|
|
23990
|
+
const oauthConfig = getOAuthConfig(name);
|
|
23991
|
+
if (!oauthConfig.clientId)
|
|
23992
|
+
return null;
|
|
23993
|
+
const scopes = GOOGLE_SCOPES[name];
|
|
23994
|
+
if (!scopes)
|
|
23995
|
+
return null;
|
|
23996
|
+
const state = randomBytes(32).toString("hex");
|
|
23997
|
+
oauthStateStore.set(state, { connector: name, createdAt: Date.now() });
|
|
23998
|
+
const tenMinutesAgo = Date.now() - 10 * 60 * 1000;
|
|
23999
|
+
for (const [key, val] of oauthStateStore) {
|
|
24000
|
+
if (val.createdAt < tenMinutesAgo)
|
|
24001
|
+
oauthStateStore.delete(key);
|
|
25211
24002
|
}
|
|
25212
|
-
|
|
25213
|
-
|
|
25214
|
-
|
|
25215
|
-
|
|
25216
|
-
|
|
25217
|
-
|
|
25218
|
-
|
|
25219
|
-
|
|
25220
|
-
proc.stdout.on("data", (data) => {
|
|
25221
|
-
stdout += data.toString();
|
|
25222
|
-
});
|
|
25223
|
-
proc.stderr.on("data", (data) => {
|
|
25224
|
-
stderr += data.toString();
|
|
25225
|
-
});
|
|
25226
|
-
proc.on("close", (code) => {
|
|
25227
|
-
resolve({
|
|
25228
|
-
stdout: stdout.trim(),
|
|
25229
|
-
stderr: stderr.trim(),
|
|
25230
|
-
exitCode: code ?? 1,
|
|
25231
|
-
success: code === 0
|
|
25232
|
-
});
|
|
25233
|
-
});
|
|
25234
|
-
proc.on("error", (err) => {
|
|
25235
|
-
resolve({
|
|
25236
|
-
stdout: "",
|
|
25237
|
-
stderr: err.message,
|
|
25238
|
-
exitCode: 1,
|
|
25239
|
-
success: false
|
|
25240
|
-
});
|
|
25241
|
-
});
|
|
24003
|
+
const params = new URLSearchParams({
|
|
24004
|
+
client_id: oauthConfig.clientId,
|
|
24005
|
+
redirect_uri: redirectUri,
|
|
24006
|
+
response_type: "code",
|
|
24007
|
+
scope: scopes,
|
|
24008
|
+
access_type: "offline",
|
|
24009
|
+
prompt: "consent",
|
|
24010
|
+
state
|
|
25242
24011
|
});
|
|
24012
|
+
return `${GOOGLE_AUTH_URL}?${params.toString()}`;
|
|
25243
24013
|
}
|
|
25244
|
-
|
|
25245
|
-
|
|
25246
|
-
|
|
25247
|
-
|
|
25248
|
-
|
|
25249
|
-
|
|
25250
|
-
|
|
25251
|
-
|
|
25252
|
-
|
|
25253
|
-
|
|
25254
|
-
|
|
25255
|
-
|
|
25256
|
-
|
|
25257
|
-
operations: operations2,
|
|
25258
|
-
helpText: internalRuntime.helpText ?? buildInternalHelpText(connectorName, internalRuntime.commands),
|
|
25259
|
-
hasCli: true
|
|
25260
|
-
};
|
|
24014
|
+
function validateOAuthState(state, expectedConnector) {
|
|
24015
|
+
if (!state)
|
|
24016
|
+
return false;
|
|
24017
|
+
const entry = oauthStateStore.get(state);
|
|
24018
|
+
if (!entry || entry.connector !== expectedConnector)
|
|
24019
|
+
return false;
|
|
24020
|
+
oauthStateStore.delete(state);
|
|
24021
|
+
return Date.now() - entry.createdAt < 10 * 60 * 1000;
|
|
24022
|
+
}
|
|
24023
|
+
async function exchangeOAuthCode(name, code, redirectUri) {
|
|
24024
|
+
const oauthConfig = getOAuthConfig(name);
|
|
24025
|
+
if (!oauthConfig.clientId || !oauthConfig.clientSecret) {
|
|
24026
|
+
throw new Error("OAuth credentials not configured for " + name);
|
|
25261
24027
|
}
|
|
25262
|
-
const
|
|
25263
|
-
|
|
25264
|
-
|
|
24028
|
+
const response = await fetch(GOOGLE_TOKEN_URL, {
|
|
24029
|
+
method: "POST",
|
|
24030
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
24031
|
+
body: new URLSearchParams({
|
|
24032
|
+
code,
|
|
24033
|
+
client_id: oauthConfig.clientId,
|
|
24034
|
+
client_secret: oauthConfig.clientSecret,
|
|
24035
|
+
redirect_uri: redirectUri,
|
|
24036
|
+
grant_type: "authorization_code"
|
|
24037
|
+
}),
|
|
24038
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT)
|
|
24039
|
+
});
|
|
24040
|
+
if (!response.ok) {
|
|
24041
|
+
const error = await response.json().catch(() => ({ error: response.statusText }));
|
|
24042
|
+
throw new Error(`Token exchange failed: ${error.error_description || error.error || response.statusText}`);
|
|
25265
24043
|
}
|
|
25266
|
-
const
|
|
25267
|
-
const
|
|
25268
|
-
|
|
25269
|
-
|
|
25270
|
-
|
|
25271
|
-
|
|
25272
|
-
|
|
25273
|
-
hasCli: true
|
|
24044
|
+
const data = await response.json();
|
|
24045
|
+
const tokens = {
|
|
24046
|
+
accessToken: data.access_token,
|
|
24047
|
+
refreshToken: data.refresh_token,
|
|
24048
|
+
expiresAt: Date.now() + data.expires_in * 1000,
|
|
24049
|
+
tokenType: data.token_type,
|
|
24050
|
+
scope: data.scope
|
|
25274
24051
|
};
|
|
24052
|
+
saveOAuthTokens(name, tokens);
|
|
24053
|
+
return tokens;
|
|
25275
24054
|
}
|
|
25276
|
-
|
|
25277
|
-
const
|
|
25278
|
-
const
|
|
25279
|
-
|
|
25280
|
-
|
|
25281
|
-
|
|
25282
|
-
|
|
25283
|
-
|
|
24055
|
+
function saveOAuthTokens(name, tokens) {
|
|
24056
|
+
const configDir = getConnectorConfigDir(name);
|
|
24057
|
+
const profile = getCurrentProfile2(name);
|
|
24058
|
+
const profileDir = join15(configDir, "profiles", profile);
|
|
24059
|
+
mkdirSync9(profileDir, { recursive: true });
|
|
24060
|
+
const tokensFile = join15(profileDir, "tokens.json");
|
|
24061
|
+
writeFileSync5(tokensFile, JSON.stringify(tokens, null, 2), { mode: 384 });
|
|
24062
|
+
}
|
|
24063
|
+
async function refreshOAuthToken(name) {
|
|
24064
|
+
return withWriteLock(name, () => _refreshOAuthToken(name));
|
|
24065
|
+
}
|
|
24066
|
+
async function _refreshOAuthToken(name) {
|
|
24067
|
+
const oauthConfig = getOAuthConfig(name);
|
|
24068
|
+
const currentTokens = loadTokens(name);
|
|
24069
|
+
if (!oauthConfig.clientId || !oauthConfig.clientSecret) {
|
|
24070
|
+
throw new Error("OAuth credentials not configured for " + name);
|
|
25284
24071
|
}
|
|
25285
|
-
|
|
25286
|
-
|
|
25287
|
-
return runtimeCommand.helpText;
|
|
24072
|
+
if (!currentTokens?.refreshToken) {
|
|
24073
|
+
throw new Error("No refresh token available. Please re-authenticate.");
|
|
25288
24074
|
}
|
|
25289
|
-
const
|
|
25290
|
-
|
|
24075
|
+
const response = await fetch(GOOGLE_TOKEN_URL, {
|
|
24076
|
+
method: "POST",
|
|
24077
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
24078
|
+
body: new URLSearchParams({
|
|
24079
|
+
client_id: oauthConfig.clientId,
|
|
24080
|
+
client_secret: oauthConfig.clientSecret,
|
|
24081
|
+
refresh_token: currentTokens.refreshToken,
|
|
24082
|
+
grant_type: "refresh_token"
|
|
24083
|
+
}),
|
|
24084
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT)
|
|
24085
|
+
});
|
|
24086
|
+
if (!response.ok) {
|
|
24087
|
+
const error = await response.json().catch(() => ({ error: response.statusText }));
|
|
24088
|
+
throw new Error(`Token refresh failed: ${error.error_description || error.error}`);
|
|
24089
|
+
}
|
|
24090
|
+
const data = await response.json();
|
|
24091
|
+
const tokens = {
|
|
24092
|
+
accessToken: data.access_token,
|
|
24093
|
+
refreshToken: currentTokens.refreshToken,
|
|
24094
|
+
expiresAt: Date.now() + data.expires_in * 1000,
|
|
24095
|
+
tokenType: data.token_type,
|
|
24096
|
+
scope: data.scope || currentTokens.scope
|
|
24097
|
+
};
|
|
24098
|
+
saveOAuthTokens(name, tokens);
|
|
24099
|
+
return tokens;
|
|
25291
24100
|
}
|
|
25292
|
-
|
|
25293
|
-
|
|
25294
|
-
|
|
25295
|
-
|
|
25296
|
-
|
|
25297
|
-
|
|
25298
|
-
|
|
25299
|
-
|
|
25300
|
-
|
|
25301
|
-
|
|
25302
|
-
|
|
24101
|
+
function listProfiles2(name) {
|
|
24102
|
+
const configDir = getConnectorConfigDir(name);
|
|
24103
|
+
const profilesDir = join15(configDir, "profiles");
|
|
24104
|
+
if (!existsSync14(profilesDir))
|
|
24105
|
+
return ["default"];
|
|
24106
|
+
const seen = new Set;
|
|
24107
|
+
try {
|
|
24108
|
+
const entries = readdirSync8(profilesDir);
|
|
24109
|
+
for (const entry of entries) {
|
|
24110
|
+
const fullPath = join15(profilesDir, entry);
|
|
24111
|
+
const stat = statSync5(fullPath);
|
|
24112
|
+
if (stat.isDirectory()) {
|
|
24113
|
+
seen.add(entry);
|
|
24114
|
+
} else if (entry.endsWith(".json")) {
|
|
24115
|
+
seen.add(entry.replace(/\.json$/, ""));
|
|
24116
|
+
}
|
|
24117
|
+
}
|
|
24118
|
+
} catch {}
|
|
24119
|
+
seen.add("default");
|
|
24120
|
+
return Array.from(seen).sort();
|
|
25303
24121
|
}
|
|
25304
|
-
|
|
25305
|
-
const
|
|
25306
|
-
|
|
25307
|
-
|
|
25308
|
-
return null;
|
|
25309
|
-
const docs = getConnectorDocs(connectorName);
|
|
25310
|
-
const configPaths = resolveConnectorConfigPaths(connectorName);
|
|
25311
|
-
const operations = await loadOperations(connectorName, options.includeOperations);
|
|
25312
|
-
return {
|
|
25313
|
-
...meta,
|
|
25314
|
-
id: connectorName,
|
|
25315
|
-
aliases: buildAliases(connectorName),
|
|
25316
|
-
runtime: {
|
|
25317
|
-
packageName: "@hasna/connectors",
|
|
25318
|
-
connectorId: connectorName,
|
|
25319
|
-
legacyConnectorId: legacyConnectorName(connectorName),
|
|
25320
|
-
packagePath: getConnectorPath(connectorName),
|
|
25321
|
-
configDirName: configPaths.preferredDirName,
|
|
25322
|
-
legacyConfigDirName: configPaths.legacyName,
|
|
25323
|
-
internal: Boolean(getInternalConnectorDefinition(connectorName)),
|
|
25324
|
-
packageDirectory: connectorExists(connectorName),
|
|
25325
|
-
commandSurface: hasConnectorCommandSurface(connectorName)
|
|
25326
|
-
},
|
|
25327
|
-
auth: {
|
|
25328
|
-
type: getAuthType(connectorName),
|
|
25329
|
-
summary: docs?.auth ?? null,
|
|
25330
|
-
envVars: docs?.envVars ?? []
|
|
25331
|
-
},
|
|
25332
|
-
docs: {
|
|
25333
|
-
overview: docs?.overview ?? "",
|
|
25334
|
-
cliCommands: docs?.cliCommands ?? "",
|
|
25335
|
-
dataStorage: docs?.dataStorage ?? null
|
|
25336
|
-
},
|
|
25337
|
-
...operations ? { operations } : {}
|
|
25338
|
-
};
|
|
24122
|
+
function switchProfile(name, profile) {
|
|
24123
|
+
const configDir = getConnectorConfigDir(name);
|
|
24124
|
+
mkdirSync9(configDir, { recursive: true });
|
|
24125
|
+
writeFileSync5(join15(configDir, "current_profile"), profile);
|
|
25339
24126
|
}
|
|
25340
|
-
|
|
25341
|
-
|
|
25342
|
-
|
|
25343
|
-
|
|
25344
|
-
|
|
25345
|
-
|
|
25346
|
-
|
|
24127
|
+
function deleteProfile2(name, profile) {
|
|
24128
|
+
if (profile === "default")
|
|
24129
|
+
return false;
|
|
24130
|
+
const configDir = getConnectorConfigDir(name);
|
|
24131
|
+
const profilesDir = join15(configDir, "profiles");
|
|
24132
|
+
const profileFile = join15(profilesDir, `${profile}.json`);
|
|
24133
|
+
if (existsSync14(profileFile)) {
|
|
24134
|
+
rmSync3(profileFile);
|
|
24135
|
+
if (getCurrentProfile2(name) === profile) {
|
|
24136
|
+
switchProfile(name, "default");
|
|
24137
|
+
}
|
|
24138
|
+
return true;
|
|
25347
24139
|
}
|
|
25348
|
-
|
|
25349
|
-
|
|
25350
|
-
|
|
25351
|
-
|
|
25352
|
-
|
|
25353
|
-
|
|
25354
|
-
|
|
25355
|
-
|
|
25356
|
-
|
|
24140
|
+
const profileDir = join15(profilesDir, profile);
|
|
24141
|
+
if (existsSync14(profileDir)) {
|
|
24142
|
+
rmSync3(profileDir, { recursive: true });
|
|
24143
|
+
if (getCurrentProfile2(name) === profile) {
|
|
24144
|
+
switchProfile(name, "default");
|
|
24145
|
+
}
|
|
24146
|
+
return true;
|
|
24147
|
+
}
|
|
24148
|
+
return false;
|
|
25357
24149
|
}
|
|
25358
24150
|
|
|
25359
24151
|
// src/server/serve.ts
|
|
@@ -25369,20 +24161,20 @@ function resolveDashboardDir() {
|
|
|
25369
24161
|
const candidates = [];
|
|
25370
24162
|
try {
|
|
25371
24163
|
const scriptDir = dirname8(fileURLToPath6(import.meta.url));
|
|
25372
|
-
candidates.push(
|
|
25373
|
-
candidates.push(
|
|
24164
|
+
candidates.push(join16(scriptDir, "..", "dashboard", "dist"));
|
|
24165
|
+
candidates.push(join16(scriptDir, "..", "..", "dashboard", "dist"));
|
|
25374
24166
|
} catch {}
|
|
25375
24167
|
if (process.argv[1]) {
|
|
25376
24168
|
const mainDir = dirname8(process.argv[1]);
|
|
25377
|
-
candidates.push(
|
|
25378
|
-
candidates.push(
|
|
24169
|
+
candidates.push(join16(mainDir, "..", "dashboard", "dist"));
|
|
24170
|
+
candidates.push(join16(mainDir, "..", "..", "dashboard", "dist"));
|
|
25379
24171
|
}
|
|
25380
|
-
candidates.push(
|
|
24172
|
+
candidates.push(join16(process.cwd(), "dashboard", "dist"));
|
|
25381
24173
|
for (const candidate of candidates) {
|
|
25382
|
-
if (
|
|
24174
|
+
if (existsSync15(candidate))
|
|
25383
24175
|
return candidate;
|
|
25384
24176
|
}
|
|
25385
|
-
return
|
|
24177
|
+
return join16(process.cwd(), "dashboard", "dist");
|
|
25386
24178
|
}
|
|
25387
24179
|
var MIME_TYPES = {
|
|
25388
24180
|
".html": "text/html; charset=utf-8",
|
|
@@ -25428,6 +24220,9 @@ function htmlResponse(content, status = 200) {
|
|
|
25428
24220
|
headers: { "Content-Type": "text/html; charset=utf-8", ...SECURITY_HEADERS }
|
|
25429
24221
|
});
|
|
25430
24222
|
}
|
|
24223
|
+
function isValidConnectorName(name) {
|
|
24224
|
+
return /^[a-z0-9-]+$/.test(name);
|
|
24225
|
+
}
|
|
25431
24226
|
var MAX_BODY_SIZE = 1024 * 1024;
|
|
25432
24227
|
function getAllConnectorsWithAuth() {
|
|
25433
24228
|
const installed = new Set(getInstalledConnectors());
|
|
@@ -25481,7 +24276,7 @@ function oauthPage(type, title, message, hint, extra) {
|
|
|
25481
24276
|
</body></html>`;
|
|
25482
24277
|
}
|
|
25483
24278
|
function serveStaticFile(filePath) {
|
|
25484
|
-
if (!
|
|
24279
|
+
if (!existsSync15(filePath))
|
|
25485
24280
|
return null;
|
|
25486
24281
|
const ext = extname(filePath);
|
|
25487
24282
|
const contentType = MIME_TYPES[ext] || "application/octet-stream";
|
|
@@ -25518,7 +24313,7 @@ async function startServer(requestedPort, options) {
|
|
|
25518
24313
|
const strict = options?.strict ?? false;
|
|
25519
24314
|
loadConnectorVersions();
|
|
25520
24315
|
const dashboardDir = resolveDashboardDir();
|
|
25521
|
-
const dashboardExists =
|
|
24316
|
+
const dashboardExists = existsSync15(dashboardDir);
|
|
25522
24317
|
if (!dashboardExists) {
|
|
25523
24318
|
console.error(`
|
|
25524
24319
|
Dashboard not found at: ${dashboardDir}`);
|
|
@@ -25561,15 +24356,6 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
25561
24356
|
}
|
|
25562
24357
|
return jsonStripped(data, 200, port);
|
|
25563
24358
|
}
|
|
25564
|
-
if (path === "/api/connectors/manifest" && method === "GET") {
|
|
25565
|
-
const connectorNames = url2.searchParams.get("connectors")?.split(",").map((name) => name.trim()).filter(Boolean);
|
|
25566
|
-
const includeOperations = url2.searchParams.get("includeOperations") === "true";
|
|
25567
|
-
const manifest = await getConnectorCapabilityManifest({
|
|
25568
|
-
includeOperations,
|
|
25569
|
-
...connectorNames ? { connectorNames } : {}
|
|
25570
|
-
});
|
|
25571
|
-
return json(manifest, 200, port);
|
|
25572
|
-
}
|
|
25573
24359
|
const singleMatch = path.match(/^\/api\/connectors\/([^/]+)$/);
|
|
25574
24360
|
if (singleMatch && method === "GET") {
|
|
25575
24361
|
const name = singleMatch[1];
|
|
@@ -25643,20 +24429,6 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
25643
24429
|
return json({ error: "Request body too large" }, 413, port);
|
|
25644
24430
|
}
|
|
25645
24431
|
const body = await req.json();
|
|
25646
|
-
if (typeof body.operation === "string" && body.operation.trim()) {
|
|
25647
|
-
const result2 = await runConnectorOperation({
|
|
25648
|
-
connector: name,
|
|
25649
|
-
operation: body.operation,
|
|
25650
|
-
input: body.input,
|
|
25651
|
-
profile: body.profile,
|
|
25652
|
-
timeoutMs: body.timeout ?? 30000,
|
|
25653
|
-
parseJson: body.parseJson
|
|
25654
|
-
});
|
|
25655
|
-
if (!result2.success) {
|
|
25656
|
-
return json({ displayName: meta.displayName, ...result2 }, 400, port);
|
|
25657
|
-
}
|
|
25658
|
-
return json({ displayName: meta.displayName, ...result2 }, 200, port);
|
|
25659
|
-
}
|
|
25660
24432
|
const args = Array.isArray(body.args) ? body.args.filter((value) => typeof value === "string") : [];
|
|
25661
24433
|
if (args.length === 0) {
|
|
25662
24434
|
return json({ error: "Missing connector command arguments" }, 400, port);
|
|
@@ -25943,16 +24715,14 @@ ${result.stderr}`;
|
|
|
25943
24715
|
if (!isValidConnectorName(name))
|
|
25944
24716
|
return json({ error: "Invalid connector name" }, 400, port);
|
|
25945
24717
|
try {
|
|
25946
|
-
const profiles =
|
|
24718
|
+
const profiles = listProfiles2(name);
|
|
24719
|
+
const configDir = join16(getConnectorsHome(), name.startsWith("connect-") ? name : `connect-${name}`);
|
|
24720
|
+
const currentProfileFile = join16(configDir, "current_profile");
|
|
25947
24721
|
let current = "default";
|
|
25948
|
-
|
|
25949
|
-
|
|
25950
|
-
|
|
25951
|
-
|
|
25952
|
-
current = readFileSync9(currentProfileFile, "utf-8").trim() || "default";
|
|
25953
|
-
} catch {}
|
|
25954
|
-
break;
|
|
25955
|
-
}
|
|
24722
|
+
if (existsSync15(currentProfileFile)) {
|
|
24723
|
+
try {
|
|
24724
|
+
current = readFileSync7(currentProfileFile, "utf-8").trim() || "default";
|
|
24725
|
+
} catch {}
|
|
25956
24726
|
}
|
|
25957
24727
|
return json({ current, profiles }, 200, port);
|
|
25958
24728
|
} catch (e) {
|
|
@@ -26000,31 +24770,33 @@ ${result.stderr}`;
|
|
|
26000
24770
|
try {
|
|
26001
24771
|
const connectDir = getConnectorsHome();
|
|
26002
24772
|
const result = {};
|
|
26003
|
-
if (
|
|
26004
|
-
|
|
24773
|
+
if (existsSync15(connectDir)) {
|
|
24774
|
+
const entries = readdirSync9(connectDir, { withFileTypes: true });
|
|
24775
|
+
for (const entry of entries) {
|
|
24776
|
+
if (!entry.isDirectory() || !entry.name.startsWith("connect-"))
|
|
24777
|
+
continue;
|
|
24778
|
+
const connectorName = entry.name.replace(/^connect-/, "");
|
|
24779
|
+
const profilesDir = join16(connectDir, entry.name, "profiles");
|
|
24780
|
+
if (!existsSync15(profilesDir))
|
|
24781
|
+
continue;
|
|
26005
24782
|
const profiles = {};
|
|
26006
|
-
|
|
26007
|
-
|
|
26008
|
-
if (
|
|
26009
|
-
|
|
26010
|
-
|
|
26011
|
-
|
|
26012
|
-
|
|
26013
|
-
|
|
24783
|
+
const profileEntries = readdirSync9(profilesDir, { withFileTypes: true });
|
|
24784
|
+
for (const pEntry of profileEntries) {
|
|
24785
|
+
if (pEntry.isFile() && pEntry.name.endsWith(".json")) {
|
|
24786
|
+
const profileName = basename(pEntry.name, ".json");
|
|
24787
|
+
try {
|
|
24788
|
+
const config = JSON.parse(readFileSync7(join16(profilesDir, pEntry.name), "utf-8"));
|
|
24789
|
+
profiles[profileName] = config;
|
|
24790
|
+
} catch {}
|
|
24791
|
+
}
|
|
24792
|
+
if (pEntry.isDirectory()) {
|
|
24793
|
+
const configPath = join16(profilesDir, pEntry.name, "config.json");
|
|
24794
|
+
if (existsSync15(configPath)) {
|
|
26014
24795
|
try {
|
|
26015
|
-
const config = JSON.parse(
|
|
26016
|
-
profiles[
|
|
24796
|
+
const config = JSON.parse(readFileSync7(configPath, "utf-8"));
|
|
24797
|
+
profiles[pEntry.name] = config;
|
|
26017
24798
|
} catch {}
|
|
26018
24799
|
}
|
|
26019
|
-
if (pEntry.isDirectory()) {
|
|
26020
|
-
const configPath = join18(profilesDir, pEntry.name, "config.json");
|
|
26021
|
-
if (existsSync18(configPath)) {
|
|
26022
|
-
try {
|
|
26023
|
-
const config = JSON.parse(readFileSync9(configPath, "utf-8"));
|
|
26024
|
-
profiles[pEntry.name] = config;
|
|
26025
|
-
} catch {}
|
|
26026
|
-
}
|
|
26027
|
-
}
|
|
26028
24800
|
}
|
|
26029
24801
|
}
|
|
26030
24802
|
if (Object.keys(profiles).length > 0) {
|
|
@@ -26062,14 +24834,14 @@ ${result.stderr}`;
|
|
|
26062
24834
|
continue;
|
|
26063
24835
|
if (!data.profiles || typeof data.profiles !== "object")
|
|
26064
24836
|
continue;
|
|
26065
|
-
const connectorDir =
|
|
26066
|
-
const profilesDir =
|
|
24837
|
+
const connectorDir = join16(connectDir, `connect-${connectorName}`);
|
|
24838
|
+
const profilesDir = join16(connectorDir, "profiles");
|
|
26067
24839
|
for (const [profileName, config] of Object.entries(data.profiles)) {
|
|
26068
24840
|
if (!config || typeof config !== "object")
|
|
26069
24841
|
continue;
|
|
26070
|
-
|
|
26071
|
-
const profileFile =
|
|
26072
|
-
|
|
24842
|
+
mkdirSync10(profilesDir, { recursive: true });
|
|
24843
|
+
const profileFile = join16(profilesDir, `${profileName}.json`);
|
|
24844
|
+
writeFileSync6(profileFile, JSON.stringify(config, null, 2));
|
|
26073
24845
|
imported++;
|
|
26074
24846
|
}
|
|
26075
24847
|
}
|
|
@@ -26085,7 +24857,7 @@ ${result.stderr}`;
|
|
|
26085
24857
|
const redirectUri = `http://localhost:${port}/oauth/${name}/callback`;
|
|
26086
24858
|
const authUrl = getOAuthStartUrl(name, redirectUri);
|
|
26087
24859
|
if (!authUrl) {
|
|
26088
|
-
return htmlResponse(oauthPage("warning", "OAuth Not Available", `No OAuth client credentials found for <span class="connector">${name}</span>.`, `Run <code>connectors auth ${name}</code> or add credentials at <code>~/.hasna/connectors
|
|
24860
|
+
return htmlResponse(oauthPage("warning", "OAuth Not Available", `No OAuth client credentials found for <span class="connector">${name}</span>.`, `Run <code>connectors auth ${name}</code> or add credentials at <code>~/.hasna/connectors/connect-${name}/credentials.json</code>`));
|
|
26089
24861
|
}
|
|
26090
24862
|
return Response.redirect(authUrl, 302);
|
|
26091
24863
|
}
|
|
@@ -26124,12 +24896,12 @@ ${result.stderr}`;
|
|
|
26124
24896
|
}
|
|
26125
24897
|
if (dashboardExists && (method === "GET" || method === "HEAD")) {
|
|
26126
24898
|
if (path !== "/") {
|
|
26127
|
-
const filePath =
|
|
24899
|
+
const filePath = join16(dashboardDir, path);
|
|
26128
24900
|
const res2 = serveStaticFile(filePath);
|
|
26129
24901
|
if (res2)
|
|
26130
24902
|
return res2;
|
|
26131
24903
|
}
|
|
26132
|
-
const indexPath =
|
|
24904
|
+
const indexPath = join16(dashboardDir, "index.html");
|
|
26133
24905
|
const res = serveStaticFile(indexPath);
|
|
26134
24906
|
if (res)
|
|
26135
24907
|
return res;
|