wizards 0.1.9
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 +110 -0
- package/README.md +170 -0
- package/apps/runtime/dist/agents/architect.js +453 -0
- package/apps/runtime/dist/agents/project-assistant.js +354 -0
- package/apps/runtime/dist/agents/subscription.js +206 -0
- package/apps/runtime/dist/agents/thought.js +21 -0
- package/apps/runtime/dist/agents/website.js +197 -0
- package/apps/runtime/dist/app.js +153 -0
- package/apps/runtime/dist/auth/account.js +121 -0
- package/apps/runtime/dist/auth/index.js +329 -0
- package/apps/runtime/dist/auth/keys.js +55 -0
- package/apps/runtime/dist/auth/local-ticket.js +23 -0
- package/apps/runtime/dist/authoring/example.js +73 -0
- package/apps/runtime/dist/authoring/guide.js +259 -0
- package/apps/runtime/dist/authoring/ops.js +117 -0
- package/apps/runtime/dist/cli/autostart.js +134 -0
- package/apps/runtime/dist/cli/clients.js +44 -0
- package/apps/runtime/dist/cli/environment.js +81 -0
- package/apps/runtime/dist/cli/exec.js +45 -0
- package/apps/runtime/dist/cli/home.js +74 -0
- package/apps/runtime/dist/cli/machine.js +145 -0
- package/apps/runtime/dist/cli/main.js +125 -0
- package/apps/runtime/dist/cli/setup.js +273 -0
- package/apps/runtime/dist/cli/start.js +190 -0
- package/apps/runtime/dist/cli/status.js +120 -0
- package/apps/runtime/dist/cli/ui.js +12 -0
- package/apps/runtime/dist/cli/update.js +58 -0
- package/apps/runtime/dist/connectors/builtin.js +70 -0
- package/apps/runtime/dist/connectors/external.js +400 -0
- package/apps/runtime/dist/connectors/gmail.js +107 -0
- package/apps/runtime/dist/connectors/imap.js +217 -0
- package/apps/runtime/dist/connectors/index.js +266 -0
- package/apps/runtime/dist/connectors/mail.js +72 -0
- package/apps/runtime/dist/connectors/outlook.js +90 -0
- package/apps/runtime/dist/credits/credits.js +103 -0
- package/apps/runtime/dist/credits/estimate.js +132 -0
- package/apps/runtime/dist/db/adopt.js +149 -0
- package/apps/runtime/dist/db/client.js +146 -0
- package/apps/runtime/dist/db/control-schema.js +70 -0
- package/apps/runtime/dist/db/migrations/control/0000_last_absorbing_man.sql +47 -0
- package/apps/runtime/dist/db/migrations/control/0001_gorgeous_nicolaos.sql +41 -0
- package/apps/runtime/dist/db/migrations/control/0002_secret_penance.sql +1 -0
- package/apps/runtime/dist/db/migrations/control/0003_nasty_mordo.sql +3 -0
- package/apps/runtime/dist/db/migrations/control/0004_breezy_eddie_brock.sql +6 -0
- package/apps/runtime/dist/db/migrations/control/meta/0000_snapshot.json +311 -0
- package/apps/runtime/dist/db/migrations/control/meta/0001_snapshot.json +599 -0
- package/apps/runtime/dist/db/migrations/control/meta/0002_snapshot.json +607 -0
- package/apps/runtime/dist/db/migrations/control/meta/0003_snapshot.json +311 -0
- package/apps/runtime/dist/db/migrations/control/meta/0004_snapshot.json +350 -0
- package/apps/runtime/dist/db/migrations/control/meta/_journal.json +41 -0
- package/apps/runtime/dist/db/migrations/tenant/0000_eminent_freak.sql +188 -0
- package/apps/runtime/dist/db/migrations/tenant/0001_salty_master_chief.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0002_cloudy_firebird.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0003_brown_warbound.sql +52 -0
- package/apps/runtime/dist/db/migrations/tenant/0004_romantic_nocturne.sql +6 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0000_snapshot.json +1323 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0001_snapshot.json +1330 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0002_snapshot.json +1337 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0003_snapshot.json +1605 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0004_snapshot.json +1645 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +41 -0
- package/apps/runtime/dist/db/schema.js +278 -0
- package/apps/runtime/dist/documents/parse.js +230 -0
- package/apps/runtime/dist/engenty/connections-external/build-connector.js +193 -0
- package/apps/runtime/dist/engenty/connections-external/errors.js +11 -0
- package/apps/runtime/dist/engenty/connections-external/import-service.js +270 -0
- package/apps/runtime/dist/engenty/connections-external/importer/classify.js +34 -0
- package/apps/runtime/dist/engenty/connections-external/importer/map-auth.js +185 -0
- package/apps/runtime/dist/engenty/connections-external/importer/normalize-mcp.js +63 -0
- package/apps/runtime/dist/engenty/connections-external/importer/normalize-openapi.js +130 -0
- package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +143 -0
- package/apps/runtime/dist/engenty/connections-external/invoke/mcp-client.js +143 -0
- package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +119 -0
- package/apps/runtime/dist/engenty/connections-external/oauth-dcr.js +88 -0
- package/apps/runtime/dist/engenty/connections-external/registry-client.js +336 -0
- package/apps/runtime/dist/engenty/connections-external/registry-source.js +82 -0
- package/apps/runtime/dist/engenty/connections-external/types.js +7 -0
- package/apps/runtime/dist/engenty/connections-github/connector.js +209 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/calendar.js +359 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/contacts.js +94 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +290 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +567 -0
- package/apps/runtime/dist/engenty/connections-google/definitions.js +11 -0
- package/apps/runtime/dist/engenty/connections-google/shared.js +73 -0
- package/apps/runtime/dist/engenty/connections-hubspot/connector.js +140 -0
- package/apps/runtime/dist/engenty/connections-microsoft/action.js +17 -0
- package/apps/runtime/dist/engenty/connections-microsoft/graph.js +114 -0
- package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +286 -0
- package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +464 -0
- package/apps/runtime/dist/engenty/connections-s3/s3.js +328 -0
- package/apps/runtime/dist/engenty/connections-sdk/files-capability.js +86 -0
- package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +150 -0
- package/apps/runtime/dist/engenty/connections-sdk/registry.js +89 -0
- package/apps/runtime/dist/engenty/connections-sdk/storage-capability.js +84 -0
- package/apps/runtime/dist/engenty/connections-sdk/types.js +30 -0
- package/apps/runtime/dist/engenty/connections-slack/connector.js +360 -0
- package/apps/runtime/dist/engenty/csv-import/csv-matrix.js +178 -0
- package/apps/runtime/dist/engenty/csv-import/import-sources.js +87 -0
- package/apps/runtime/dist/engenty/csv-import/parse-csv.js +129 -0
- package/apps/runtime/dist/engenty/csv-import/serialize-csv.js +20 -0
- package/apps/runtime/dist/engenty/csv-import/types.js +1 -0
- package/apps/runtime/dist/engenty/csv-import/xlsx-workbook.js +159 -0
- package/apps/runtime/dist/engenty/doc-converter/interface.js +9 -0
- package/apps/runtime/dist/engenty/doc-converter/page-break.js +92 -0
- package/apps/runtime/dist/engenty/doc-converter/providers/local/index.js +72 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/classifier.js +30 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/index.js +4 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/invoice.js +73 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/receipt.js +63 -0
- package/apps/runtime/dist/engenty/document-scanner/schemas/shared.js +40 -0
- package/apps/runtime/dist/engenty/search-index/chunks.js +164 -0
- package/apps/runtime/dist/engenty/search-index/contracts.js +9 -0
- package/apps/runtime/dist/engenty/shims/connections-sdk.js +39 -0
- package/apps/runtime/dist/engenty/shims/plugin-sdk.js +1 -0
- package/apps/runtime/dist/engenty/shims/web-ingest.js +3 -0
- package/apps/runtime/dist/engenty/web-ingest/ssrf.js +277 -0
- package/apps/runtime/dist/engine/asks.js +60 -0
- package/apps/runtime/dist/engine/events.js +46 -0
- package/apps/runtime/dist/engine/input.js +170 -0
- package/apps/runtime/dist/engine/prepare.js +51 -0
- package/apps/runtime/dist/engine/requirements.js +124 -0
- package/apps/runtime/dist/engine/resources.js +89 -0
- package/apps/runtime/dist/engine/runner.js +560 -0
- package/apps/runtime/dist/engine/steps.js +598 -0
- package/apps/runtime/dist/engine/template.js +183 -0
- package/apps/runtime/dist/engine/types.js +3 -0
- package/apps/runtime/dist/env.js +224 -0
- package/apps/runtime/dist/files/blobs.js +22 -0
- package/apps/runtime/dist/files/objects.js +86 -0
- package/apps/runtime/dist/files/storage.js +95 -0
- package/apps/runtime/dist/geocode.js +58 -0
- package/apps/runtime/dist/harness/claude.js +138 -0
- package/apps/runtime/dist/harness/codex.js +228 -0
- package/apps/runtime/dist/harness/cursor.js +93 -0
- package/apps/runtime/dist/harness/env.js +124 -0
- package/apps/runtime/dist/harness/gemini.js +126 -0
- package/apps/runtime/dist/harness/index.js +99 -0
- package/apps/runtime/dist/harness/model.js +267 -0
- package/apps/runtime/dist/harness/prompt.js +121 -0
- package/apps/runtime/dist/harness/terminal.js +193 -0
- package/apps/runtime/dist/harness/types.js +7 -0
- package/apps/runtime/dist/index.js +76 -0
- package/apps/runtime/dist/limits.js +57 -0
- package/apps/runtime/dist/link-preview.js +59 -0
- package/apps/runtime/dist/manage.js +151 -0
- package/apps/runtime/dist/mcp/auth.js +102 -0
- package/apps/runtime/dist/mcp/bridge.js +59 -0
- package/apps/runtime/dist/mcp/handler.js +42 -0
- package/apps/runtime/dist/mcp/scopes.js +5 -0
- package/apps/runtime/dist/mcp/tools.js +401 -0
- package/apps/runtime/dist/media/ffmpeg.js +121 -0
- package/apps/runtime/dist/media/generate.js +120 -0
- package/apps/runtime/dist/media/marking.js +121 -0
- package/apps/runtime/dist/media/transcribe.js +30 -0
- package/apps/runtime/dist/model-errors.js +3 -0
- package/apps/runtime/dist/models.js +489 -0
- package/apps/runtime/dist/plugin.js +61 -0
- package/apps/runtime/dist/render/chromium.js +85 -0
- package/apps/runtime/dist/render/convert.js +161 -0
- package/apps/runtime/dist/render/downloads.js +277 -0
- package/apps/runtime/dist/render/guard.js +25 -0
- package/apps/runtime/dist/routes/api.js +74 -0
- package/apps/runtime/dist/routes/delivery.js +52 -0
- package/apps/runtime/dist/routes/internal.js +49 -0
- package/apps/runtime/dist/routes/marketplace.js +36 -0
- package/apps/runtime/dist/routes/runs.js +805 -0
- package/apps/runtime/dist/routes/studio.js +702 -0
- package/apps/runtime/dist/routes/wizard-stream.js +30 -0
- package/apps/runtime/dist/running.js +39 -0
- package/apps/runtime/dist/sandbox/agentos.js +191 -0
- package/apps/runtime/dist/sandbox/docker.js +77 -0
- package/apps/runtime/dist/sandbox/index.js +30 -0
- package/apps/runtime/dist/sandbox/types.js +1 -0
- package/apps/runtime/dist/secrets/crypto.js +28 -0
- package/apps/runtime/dist/secrets/signing.js +34 -0
- package/apps/runtime/dist/secrets/vault.js +59 -0
- package/apps/runtime/dist/services/architect.js +92 -0
- package/apps/runtime/dist/services/brand.js +20 -0
- package/apps/runtime/dist/services/cloud.js +52 -0
- package/apps/runtime/dist/services/draft-events.js +27 -0
- package/apps/runtime/dist/services/errors.js +24 -0
- package/apps/runtime/dist/services/files.js +129 -0
- package/apps/runtime/dist/services/links.js +16 -0
- package/apps/runtime/dist/services/marketplace.js +292 -0
- package/apps/runtime/dist/services/package.js +202 -0
- package/apps/runtime/dist/services/profile.js +23 -0
- package/apps/runtime/dist/services/project-files.js +266 -0
- package/apps/runtime/dist/services/project-index.js +109 -0
- package/apps/runtime/dist/services/projects.js +181 -0
- package/apps/runtime/dist/services/runs.js +224 -0
- package/apps/runtime/dist/services/shares.js +129 -0
- package/apps/runtime/dist/services/widgets.js +34 -0
- package/apps/runtime/dist/services/wizards.js +342 -0
- package/apps/runtime/dist/settings.js +16 -0
- package/apps/runtime/dist/store/index.js +279 -0
- package/apps/runtime/dist/tenants/control.js +106 -0
- package/apps/runtime/dist/tenants/tenant.js +26 -0
- package/apps/runtime/dist/tools/browser.js +380 -0
- package/apps/runtime/dist/tools/connector.js +204 -0
- package/apps/runtime/dist/tools/index.js +234 -0
- package/apps/runtime/dist/tools/mail.js +104 -0
- package/apps/runtime/dist/tools/net-guard.js +59 -0
- package/apps/runtime/dist/tools/project.js +53 -0
- package/apps/runtime/dist/tools/shared.js +42 -0
- package/apps/runtime/dist/tools/store.js +238 -0
- package/apps/runtime/dist/update.js +118 -0
- package/apps/runtime/dist/widgets/bundle.js +99 -0
- package/apps/runtime/dist/widgets/render.js +312 -0
- package/apps/runtime/dist/widgets/runtime.js +84 -0
- package/apps/runtime/dist/widgets/script.js +30 -0
- package/apps/runtime/dist/widgets/step.js +192 -0
- package/apps/web/dist/ai-labels/ai-black.svg +20 -0
- package/apps/web/dist/ai-labels/ai-generated-black.svg +31 -0
- package/apps/web/dist/ai-labels/ai-generated-white.svg +32 -0
- package/apps/web/dist/ai-labels/ai-modified-black.svg +30 -0
- package/apps/web/dist/ai-labels/ai-modified-white.svg +31 -0
- package/apps/web/dist/ai-labels/ai-white.svg +21 -0
- package/apps/web/dist/assets/ChangelogDialog-O00vEnbm.js +1 -0
- package/apps/web/dist/assets/ChatPanel-CH9ry0Hp.js +1 -0
- package/apps/web/dist/assets/CreditsDialog-DRzecwUw.js +1 -0
- package/apps/web/dist/assets/EditorPage-BRnBf02Q.js +2 -0
- package/apps/web/dist/assets/FlowPreview-DDOj8IAH.js +1 -0
- package/apps/web/dist/assets/HomePage-CAGTTG3N.js +1 -0
- package/apps/web/dist/assets/ImportWizard-0RRrAnX3.js +1 -0
- package/apps/web/dist/assets/LocalRuntime-BrP-ENHg.css +1 -0
- package/apps/web/dist/assets/LocalRuntime-C-TBYrzs.js +16 -0
- package/apps/web/dist/assets/NewWizardPage-kI90h3_9.js +2 -0
- package/apps/web/dist/assets/PublicRunner-CKRDeIVd.js +1 -0
- package/apps/web/dist/assets/RunnerView-Rc4H8wYH.js +2 -0
- package/apps/web/dist/assets/SettingsPage-CESMuZxq.js +2 -0
- package/apps/web/dist/assets/SetupPage-D1rrYU14.js +1 -0
- package/apps/web/dist/assets/SharePage-COTAmOgh.js +1 -0
- package/apps/web/dist/assets/api-BY28cjGY.js +10 -0
- package/apps/web/dist/assets/arrow-left-UpjOBfQp.js +1 -0
- package/apps/web/dist/assets/arrow-right-CucQycEy.js +1 -0
- package/apps/web/dist/assets/changelog-p3wsaDDS.js +1 -0
- package/apps/web/dist/assets/check-Bjx41xbB.js +1 -0
- package/apps/web/dist/assets/createLucideIcon-DBu2Ovxj.js +1 -0
- package/apps/web/dist/assets/definition-cy7uvY5L.js +55 -0
- package/apps/web/dist/assets/engenty-CWIFpgKq.js +1 -0
- package/apps/web/dist/assets/esm-D1OEhjTK.js +7 -0
- package/apps/web/dist/assets/external-link-CRg6DVdO.js +1 -0
- package/apps/web/dist/assets/fluffy-engenty-CJ3wCQgT.js +456 -0
- package/apps/web/dist/assets/index-CQ_q9iMO.css +1 -0
- package/apps/web/dist/assets/index-D0gxh90t.js +10 -0
- package/apps/web/dist/assets/jsx-runtime-Dk72oS4N.js +1 -0
- package/apps/web/dist/assets/meta-BbSdtTUa.js +1 -0
- package/apps/web/dist/assets/mic-CeqQ89Dj.js +1 -0
- package/apps/web/dist/assets/oss-credits-cPuZUFHD.js +1 -0
- package/apps/web/dist/assets/outputs-D6pxH6ve.js +69 -0
- package/apps/web/dist/assets/plus-HA210wXA.js +1 -0
- package/apps/web/dist/assets/preload-helper-CNEI7N0N.js +1 -0
- package/apps/web/dist/assets/qr-scanner-worker.min-CJaXo3yu.js +98 -0
- package/apps/web/dist/assets/qr-scanner.min-C_UI0gH-.js +1 -0
- package/apps/web/dist/assets/type-BzYgVWKL.js +1 -0
- package/apps/web/dist/assets/ui-Ddwl35A6.js +1 -0
- package/apps/web/dist/assets/upload-DsgLfQ3U.js +1 -0
- package/apps/web/dist/assets/video-Dk1fuTDl.js +1 -0
- package/apps/web/dist/assets/wand-sparkles-Bf97fs8T.js +1 -0
- package/apps/web/dist/embed.js +102 -0
- package/apps/web/dist/favicon.svg +1 -0
- package/apps/web/dist/icons/apple-touch-icon.png +0 -0
- package/apps/web/dist/icons/icon-192.png +0 -0
- package/apps/web/dist/icons/icon-512.png +0 -0
- package/apps/web/dist/icons/icon-maskable-512.png +0 -0
- package/apps/web/dist/index.html +46 -0
- package/apps/web/dist/install.sh +532 -0
- package/apps/web/dist/manifest.webmanifest +20 -0
- package/apps/web/dist/sw.js +15 -0
- package/bin/wizards.mjs +13 -0
- package/node_modules/@engenty-wizards/shared/dist/connectors.d.ts +77 -0
- package/node_modules/@engenty-wizards/shared/dist/connectors.js +2 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +1415 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.js +762 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.d.ts +5 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-format.js +132 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.d.ts +11 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns-value.js +209 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.d.ts +532 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/columns.js +216 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.d.ts +3 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/data-tables/index.js +3 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.d.ts +14 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-lexical.js +166 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.d.ts +33 -0
- package/node_modules/@engenty-wizards/shared/dist/engenty/search-index/catalog-rank.js +99 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.d.ts +35 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.js +86 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.d.ts +20 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.js +133 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +298 -0
- package/node_modules/@engenty-wizards/shared/dist/marketplace.js +211 -0
- package/node_modules/@engenty-wizards/shared/dist/merge.d.ts +7 -0
- package/node_modules/@engenty-wizards/shared/dist/merge.js +40 -0
- package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +74 -0
- package/node_modules/@engenty-wizards/shared/dist/projects.js +96 -0
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +219 -0
- package/node_modules/@engenty-wizards/shared/dist/run.js +1 -0
- package/node_modules/@engenty-wizards/shared/dist/store.d.ts +100 -0
- package/node_modules/@engenty-wizards/shared/dist/store.js +44 -0
- package/node_modules/@engenty-wizards/shared/dist/workspace.d.ts +16 -0
- package/node_modules/@engenty-wizards/shared/dist/workspace.js +51 -0
- package/node_modules/@engenty-wizards/shared/package.json +10 -0
- package/package.json +62 -0
- package/plugin/.claude-plugin/plugin.json +9 -0
- package/plugin/.mcp.json +8 -0
- package/plugin/commands/wizard.md +8 -0
- package/plugin/skills/build-wizard/SKILL.md +27 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { defineConnector, } from "../../shims/connections-sdk.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { connectorAction, GOOGLE_OAUTH2, googleFetch, googleJson, } from "../shared.js";
|
|
4
|
+
const DRIVE_API = "https://www.googleapis.com/drive/v3";
|
|
5
|
+
const DRIVE_UPLOAD_API = "https://www.googleapis.com/upload/drive/v3";
|
|
6
|
+
const SCOPE_READONLY = "https://www.googleapis.com/auth/drive.readonly";
|
|
7
|
+
const SCOPE_FILE = "https://www.googleapis.com/auth/drive.file";
|
|
8
|
+
/** ~50KB cap on file content returned to agents. */
|
|
9
|
+
const MAX_CONTENT_CHARS = 50_000;
|
|
10
|
+
function toFileSummary(f) {
|
|
11
|
+
return {
|
|
12
|
+
id: f.id,
|
|
13
|
+
mime_type: f.mimeType ?? null,
|
|
14
|
+
modified_time: f.modifiedTime ?? null,
|
|
15
|
+
name: f.name ?? null,
|
|
16
|
+
size: f.size ? Number(f.size) : null,
|
|
17
|
+
web_view_link: f.webViewLink ?? null,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Escape a value for use inside single quotes in a Drive query. */
|
|
21
|
+
function escapeDriveQueryValue(value) {
|
|
22
|
+
return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
23
|
+
}
|
|
24
|
+
const FOLDER_MIME = "application/vnd.google-apps.folder";
|
|
25
|
+
const ENTRY_FIELDS = "id,name,mimeType,modifiedTime,size,webViewLink";
|
|
26
|
+
function toCapabilityEntry(f) {
|
|
27
|
+
return {
|
|
28
|
+
kind: f.mimeType === FOLDER_MIME ? "folder" : "file",
|
|
29
|
+
mime_type: f.mimeType ?? null,
|
|
30
|
+
modified_at: f.modifiedTime ?? null,
|
|
31
|
+
name: f.name ?? "",
|
|
32
|
+
ref: f.id,
|
|
33
|
+
size: f.size ? Number(f.size) : null,
|
|
34
|
+
web_url: f.webViewLink ?? null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Export MIME type for Google Workspace documents, or null if not exportable as text. */
|
|
38
|
+
function exportMimeFor(mimeType) {
|
|
39
|
+
switch (mimeType) {
|
|
40
|
+
case "application/vnd.google-apps.document":
|
|
41
|
+
case "application/vnd.google-apps.presentation":
|
|
42
|
+
return "text/plain";
|
|
43
|
+
case "application/vnd.google-apps.spreadsheet":
|
|
44
|
+
return "text/csv";
|
|
45
|
+
default:
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export const driveConnector = defineConnector({
|
|
50
|
+
actions: [
|
|
51
|
+
connectorAction({
|
|
52
|
+
description: "Search Google Drive files by a Drive query expression and/or a name substring. Returns id, name, MIME type, modified time, size and web link.",
|
|
53
|
+
group: "read",
|
|
54
|
+
handler: async (input, ctx) => {
|
|
55
|
+
const qParts = ["trashed = false"];
|
|
56
|
+
if (input.query) {
|
|
57
|
+
qParts.push(`(${input.query})`);
|
|
58
|
+
}
|
|
59
|
+
if (input.name_contains) {
|
|
60
|
+
qParts.push(`name contains '${escapeDriveQueryValue(input.name_contains)}'`);
|
|
61
|
+
}
|
|
62
|
+
const url = new URL(`${DRIVE_API}/files`);
|
|
63
|
+
url.searchParams.set("q", qParts.join(" and "));
|
|
64
|
+
url.searchParams.set("pageSize", String(input.page_size ?? 10));
|
|
65
|
+
url.searchParams.set("fields", "files(id,name,mimeType,modifiedTime,size,webViewLink)");
|
|
66
|
+
const data = await googleJson(ctx, url.toString());
|
|
67
|
+
return { files: (data.files ?? []).map(toFileSummary) };
|
|
68
|
+
},
|
|
69
|
+
id: "search_files",
|
|
70
|
+
inputSchema: z.object({
|
|
71
|
+
name_contains: z
|
|
72
|
+
.string()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("Only return files whose name contains this substring."),
|
|
75
|
+
page_size: z
|
|
76
|
+
.number()
|
|
77
|
+
.int()
|
|
78
|
+
.min(1)
|
|
79
|
+
.max(25)
|
|
80
|
+
.optional()
|
|
81
|
+
.describe("Maximum number of files to return (1-25, default 10)."),
|
|
82
|
+
query: z
|
|
83
|
+
.string()
|
|
84
|
+
.optional()
|
|
85
|
+
.describe("Raw Drive query expression (https://developers.google.com/drive/api/guides/search-files), e.g. \"mimeType = 'application/pdf' and modifiedTime > '2026-01-01T00:00:00'\"."),
|
|
86
|
+
}),
|
|
87
|
+
providerScopes: [SCOPE_READONLY],
|
|
88
|
+
summary: "Search Google Drive files",
|
|
89
|
+
}),
|
|
90
|
+
connectorAction({
|
|
91
|
+
description: "Fetch metadata for a Google Drive file: name, MIME type, size, timestamps, owners, parent folder and web link.",
|
|
92
|
+
group: "read",
|
|
93
|
+
handler: async (input, ctx) => {
|
|
94
|
+
const f = await googleJson(ctx, `${DRIVE_API}/files/${encodeURIComponent(input.file_id)}?fields=id,name,mimeType,size,createdTime,modifiedTime,webViewLink,parents,owners(displayName,emailAddress)`);
|
|
95
|
+
return {
|
|
96
|
+
...toFileSummary(f),
|
|
97
|
+
created_time: f.createdTime ?? null,
|
|
98
|
+
owners: (f.owners ?? []).map((o) => ({
|
|
99
|
+
display_name: o.displayName ?? null,
|
|
100
|
+
email: o.emailAddress ?? null,
|
|
101
|
+
})),
|
|
102
|
+
parents: f.parents ?? [],
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
id: "get_file_metadata",
|
|
106
|
+
inputSchema: z.object({
|
|
107
|
+
file_id: z.string().describe("Google Drive file id."),
|
|
108
|
+
}),
|
|
109
|
+
providerScopes: [SCOPE_READONLY],
|
|
110
|
+
summary: "Get Drive file metadata",
|
|
111
|
+
}),
|
|
112
|
+
connectorAction({
|
|
113
|
+
description: "Read the text content of a Google Drive file. Plain text and JSON files are downloaded directly; Google Docs/Slides are exported as plain text and Google Sheets as CSV. Output is capped at ~50KB (truncated flag set when cut off).",
|
|
114
|
+
group: "read",
|
|
115
|
+
handler: async (input, ctx) => {
|
|
116
|
+
const meta = await googleJson(ctx, `${DRIVE_API}/files/${encodeURIComponent(input.file_id)}?fields=id,name,mimeType,size`);
|
|
117
|
+
const mimeType = meta.mimeType ?? "application/octet-stream";
|
|
118
|
+
const exportMime = mimeType.startsWith("application/vnd.google-apps")
|
|
119
|
+
? exportMimeFor(mimeType)
|
|
120
|
+
: null;
|
|
121
|
+
let res;
|
|
122
|
+
if (exportMime) {
|
|
123
|
+
res = await googleFetch(ctx, `${DRIVE_API}/files/${encodeURIComponent(input.file_id)}/export?mimeType=${encodeURIComponent(exportMime)}`);
|
|
124
|
+
}
|
|
125
|
+
else if (mimeType.startsWith("text/") ||
|
|
126
|
+
mimeType === "application/json") {
|
|
127
|
+
res = await googleFetch(ctx, `${DRIVE_API}/files/${encodeURIComponent(input.file_id)}?alt=media`);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
throw new Error(`google_drive_unsupported_type: cannot read "${mimeType}" as text. Supported: text/*, application/json, Google Docs, Sheets and Slides.`);
|
|
131
|
+
}
|
|
132
|
+
const text = await res.text();
|
|
133
|
+
const truncated = text.length > MAX_CONTENT_CHARS;
|
|
134
|
+
return {
|
|
135
|
+
content: truncated ? text.slice(0, MAX_CONTENT_CHARS) : text,
|
|
136
|
+
export_mime_type: exportMime,
|
|
137
|
+
file_id: meta.id,
|
|
138
|
+
mime_type: mimeType,
|
|
139
|
+
name: meta.name ?? null,
|
|
140
|
+
truncated,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
id: "read_file_content",
|
|
144
|
+
inputSchema: z.object({
|
|
145
|
+
file_id: z
|
|
146
|
+
.string()
|
|
147
|
+
.describe("Google Drive file id. Must be a text-like file (text/*, JSON) or a Google Doc/Sheet/Slides."),
|
|
148
|
+
}),
|
|
149
|
+
providerScopes: [SCOPE_READONLY],
|
|
150
|
+
summary: "Read Drive file content as text",
|
|
151
|
+
}),
|
|
152
|
+
connectorAction({
|
|
153
|
+
description: "Create a new file in Google Drive from text content, optionally inside a specific folder.",
|
|
154
|
+
group: "write",
|
|
155
|
+
handler: async (input, ctx) => {
|
|
156
|
+
const mimeType = input.mime_type ?? "text/plain";
|
|
157
|
+
const metadata = {
|
|
158
|
+
mimeType,
|
|
159
|
+
name: input.name,
|
|
160
|
+
...(input.folder_id ? { parents: [input.folder_id] } : {}),
|
|
161
|
+
};
|
|
162
|
+
const boundary = `engenty_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
163
|
+
const body = [
|
|
164
|
+
`--${boundary}`,
|
|
165
|
+
"Content-Type: application/json; charset=UTF-8",
|
|
166
|
+
"",
|
|
167
|
+
JSON.stringify(metadata),
|
|
168
|
+
`--${boundary}`,
|
|
169
|
+
`Content-Type: ${mimeType}; charset=UTF-8`,
|
|
170
|
+
"",
|
|
171
|
+
input.content_text,
|
|
172
|
+
`--${boundary}--`,
|
|
173
|
+
].join("\r\n");
|
|
174
|
+
const created = await googleJson(ctx, `${DRIVE_UPLOAD_API}/files?uploadType=multipart&fields=id,name,mimeType,webViewLink`, {
|
|
175
|
+
body,
|
|
176
|
+
headers: {
|
|
177
|
+
"Content-Type": `multipart/related; boundary=${boundary}`,
|
|
178
|
+
},
|
|
179
|
+
method: "POST",
|
|
180
|
+
});
|
|
181
|
+
return {
|
|
182
|
+
file_id: created.id,
|
|
183
|
+
mime_type: created.mimeType ?? mimeType,
|
|
184
|
+
name: created.name ?? input.name,
|
|
185
|
+
web_view_link: created.webViewLink ?? null,
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
id: "create_file",
|
|
189
|
+
inputSchema: z.object({
|
|
190
|
+
content_text: z.string().describe("Text content of the new file."),
|
|
191
|
+
folder_id: z
|
|
192
|
+
.string()
|
|
193
|
+
.optional()
|
|
194
|
+
.describe("Optional Drive folder id to create the file in (default: My Drive root)."),
|
|
195
|
+
mime_type: z
|
|
196
|
+
.string()
|
|
197
|
+
.optional()
|
|
198
|
+
.describe('MIME type of the file content (default "text/plain"; e.g. "text/markdown", "text/csv", "application/json").'),
|
|
199
|
+
name: z.string().describe("File name, including extension."),
|
|
200
|
+
}),
|
|
201
|
+
providerScopes: [SCOPE_FILE],
|
|
202
|
+
summary: "Create a file in Google Drive",
|
|
203
|
+
}),
|
|
204
|
+
],
|
|
205
|
+
auth: { kind: "oauth2", oauth2: GOOGLE_OAUTH2 },
|
|
206
|
+
description: "Search, read and create files in a connected Google Drive account.",
|
|
207
|
+
files: {
|
|
208
|
+
rootLabel: () => "My Drive",
|
|
209
|
+
async list(ctx, input) {
|
|
210
|
+
const parent = input.folder_ref ?? "root";
|
|
211
|
+
const url = new URL(`${DRIVE_API}/files`);
|
|
212
|
+
url.searchParams.set("q", `'${escapeDriveQueryValue(parent)}' in parents and trashed = false`);
|
|
213
|
+
url.searchParams.set("pageSize", String(input.limit ?? 100));
|
|
214
|
+
url.searchParams.set("fields", `nextPageToken,files(${ENTRY_FIELDS})`);
|
|
215
|
+
url.searchParams.set("orderBy", "folder,name");
|
|
216
|
+
if (input.cursor) {
|
|
217
|
+
url.searchParams.set("pageToken", input.cursor);
|
|
218
|
+
}
|
|
219
|
+
const data = await googleJson(ctx, url.toString());
|
|
220
|
+
return {
|
|
221
|
+
entries: (data.files ?? []).map(toCapabilityEntry),
|
|
222
|
+
next_cursor: data.nextPageToken ?? null,
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
async read(ctx, input) {
|
|
226
|
+
const meta = await googleJson(ctx, `${DRIVE_API}/files/${encodeURIComponent(input.file_ref)}?fields=id,name,mimeType,size`);
|
|
227
|
+
const mimeType = meta.mimeType ?? "application/octet-stream";
|
|
228
|
+
const size = meta.size ? Number(meta.size) : null;
|
|
229
|
+
const cap = input.max_bytes ?? 20_000_000;
|
|
230
|
+
if (size !== null && size > cap) {
|
|
231
|
+
throw new Error(`google_drive_file_too_large: ${size} bytes exceeds the ${cap} byte cap`);
|
|
232
|
+
}
|
|
233
|
+
const exportMime = mimeType.startsWith("application/vnd.google-apps")
|
|
234
|
+
? exportMimeFor(mimeType)
|
|
235
|
+
: null;
|
|
236
|
+
if (exportMime) {
|
|
237
|
+
const res = await googleFetch(ctx, `${DRIVE_API}/files/${encodeURIComponent(input.file_ref)}/export?mimeType=${encodeURIComponent(exportMime)}`);
|
|
238
|
+
const content = await res.text();
|
|
239
|
+
return {
|
|
240
|
+
content,
|
|
241
|
+
kind: "text",
|
|
242
|
+
mime_type: exportMime,
|
|
243
|
+
name: meta.name ?? null,
|
|
244
|
+
size: content.length,
|
|
245
|
+
truncated: false,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const res = await googleFetch(ctx, `${DRIVE_API}/files/${encodeURIComponent(input.file_ref)}?alt=media`);
|
|
249
|
+
const buffer = new Uint8Array(await res.arrayBuffer());
|
|
250
|
+
const truncated = buffer.byteLength > cap;
|
|
251
|
+
const body = truncated ? buffer.subarray(0, cap) : buffer;
|
|
252
|
+
return {
|
|
253
|
+
content_base64: Buffer.from(body).toString("base64"),
|
|
254
|
+
kind: "base64",
|
|
255
|
+
mime_type: mimeType,
|
|
256
|
+
name: meta.name ?? null,
|
|
257
|
+
size: size ?? buffer.byteLength,
|
|
258
|
+
truncated,
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
async search(ctx, input) {
|
|
262
|
+
const qParts = [
|
|
263
|
+
"trashed = false",
|
|
264
|
+
`name contains '${escapeDriveQueryValue(input.query)}'`,
|
|
265
|
+
];
|
|
266
|
+
if (input.folder_ref) {
|
|
267
|
+
qParts.push(`'${escapeDriveQueryValue(input.folder_ref)}' in parents`);
|
|
268
|
+
}
|
|
269
|
+
const url = new URL(`${DRIVE_API}/files`);
|
|
270
|
+
url.searchParams.set("q", qParts.join(" and "));
|
|
271
|
+
url.searchParams.set("pageSize", String(input.limit ?? 100));
|
|
272
|
+
url.searchParams.set("fields", `files(${ENTRY_FIELDS})`);
|
|
273
|
+
const data = await googleJson(ctx, url.toString());
|
|
274
|
+
return {
|
|
275
|
+
entries: (data.files ?? []).map(toCapabilityEntry),
|
|
276
|
+
next_cursor: null,
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
async stat(ctx, input) {
|
|
280
|
+
const f = await googleJson(ctx, `${DRIVE_API}/files/${encodeURIComponent(input.ref)}?fields=${ENTRY_FIELDS}`);
|
|
281
|
+
return toCapabilityEntry(f);
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
filesProviderScopes: [SCOPE_READONLY],
|
|
285
|
+
icon: "logo:google-drive",
|
|
286
|
+
id: "google-drive",
|
|
287
|
+
moduleId: "connections-google",
|
|
288
|
+
name: "Google Drive",
|
|
289
|
+
toolPrefix: "gdrive",
|
|
290
|
+
});
|