You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup bundles everything into a single IIFE. Functions are exposed to Apps Script via `global.functionName = functionName` at the bottom of `index.ts`. If you add a new function that needs to be callable from the Sheets menu or a trigger, add it there.
105
+
Rollup bundles everything into a single IIFE assigned to `_GASEntry`. Apps Script has no module system and can only discover top-level functions in the global scope. The `footer` field in `rollup.config.js` bridges this gap by appending plain global stubs that delegate into the IIFE:
**To expose a new function to Apps Script, you must do both:**
114
+
1.`export` it from `src/server/index.ts`
115
+
2. Add a matching global stub in the `footer` of `rollup.config.js`
116
+
117
+
If you skip step 2, the function will exist in the bundle but Apps Script won't be able to discover or call it.
118
+
119
+
## Tool 4 — Run AI: Required Columns
120
+
121
+
`runBatchAI` maps columns by header name. The active sheet must contain these exact headers (case-sensitive):
122
+
123
+
| Column header | Purpose |
124
+
|---|---|
125
+
|`source_drive`| Drive file link (multimodal mode) |
126
+
|`source_text`| Plain text input (text mode) |
127
+
|`system_prompt`| System prompt for each row |
128
+
|`user_prompt`| User prompt for each row |
129
+
|`ai_inference`| Output column (written by the tool) |
130
+
131
+
The Gemini API key must be stored as a Script Property (`GEMINI_API_KEY`) in Apps Script > Project Settings > Script Properties before Tool 4 will run.
91
132
92
133
## Key Notes
93
134
94
135
**Drive Advanced Service:** The `extractTextUniversal` function uses `Drive.Files.create()` and `Drive.Files.remove()` (v3 API) for PDF/image OCR. This is the Drive *Advanced Service*, not `DriveApp`. It must be enabled separately in the Apps Script editor AND is declared in `appsscript.json` under `enabledAdvancedServices`.
95
136
96
-
**appsscript.json must be in dist/:** Clasp needs the manifest alongside the bundled JS. Either copy it manually (`cp appsscript.json dist/`) or add a Rollup copy plugin. The build script uses `rimraf dist` so you'll need to copy it after each build.
137
+
**appsscript.json must be in dist/:** Clasp needs the manifest alongside the bundled JS. The build script handles this automatically — it runs `rimraf dist`, Rollup, then copies `appsscript.json` into `dist/`. No manual copy needed.
97
138
98
139
**Custom functions have limited permissions:** The `GEMINI()` custom function (if you add one) cannot access `PropertiesService`, so passing an API key to it requires a different pattern (hardcoded config, cache, or trigger-based pre-fetch).
0 commit comments