Fix vercel (#241)

* use static imports for prebuilt cards

* fixed s3 env variables
This commit is contained in:
arkml 2025-09-11 21:39:47 +05:30 committed by GitHub
parent 5efdee18eb
commit ad7a0d313b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 47 additions and 53 deletions

View file

@ -0,0 +1,16 @@
// Static index of prebuilt workflow templates so they are bundled in Vercel
// If you add/remove a JSON here, update this file accordingly.
import githubDataToSpreadsheet from './github-data-to-spreadsheet.json';
import interviewScheduler from './interview-scheduler.json';
import meetingPrepAssistant from './Meeting Prep Assistant.json';
import redditOnSlack from './Reddit on Slack.json';
// Keep keys consistent with prior file basenames to avoid breaking links.
export const prebuiltTemplates = {
'github-data-to-spreadsheet': githubDataToSpreadsheet,
'interview-scheduler': interviewScheduler,
'Meeting Prep Assistant': meetingPrepAssistant,
'Reddit on Slack': redditOnSlack,
};

View file

@ -1,19 +1,13 @@
import { WorkflowTemplate } from "./types/workflow_types";
import { z } from 'zod';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import { prebuiltTemplates } from './prebuilt-cards';
const DEFAULT_MODEL = process.env.PROVIDER_DEFAULT_MODEL || "gpt-4.1";
// Function to load prebuilt cards from JSON files
function loadTemplatesFromFiles(): { [key: string]: z.infer<typeof WorkflowTemplate> } {
const templatesDir = path.join(__dirname, 'prebuilt-cards');
// Build templates object using static imports so Vercel bundles them
function buildTemplates(): { [key: string]: z.infer<typeof WorkflowTemplate> } {
const templates: { [key: string]: z.infer<typeof WorkflowTemplate> } = {};
// Add default template
templates['default'] = {
name: 'Blank Template',
@ -51,41 +45,19 @@ function loadTemplatesFromFiles(): { [key: string]: z.infer<typeof WorkflowTempl
},
],
};
try {
// Check if prebuilt cards directory exists
if (fs.existsSync(templatesDir)) {
const files = fs.readdirSync(templatesDir);
// Load each JSON file
files.forEach(file => {
if (path.extname(file) === '.json') {
try {
const filePath = path.join(templatesDir, file);
const fileContent = fs.readFileSync(filePath, 'utf-8');
const templateData = JSON.parse(fileContent);
// Use filename without extension as template key
const templateKey = path.basename(file, '.json');
// Validate template structure (optional - you can add more validation)
if (templateData.agents && Array.isArray(templateData.agents)) {
templates[templateKey] = templateData;
}
} catch (error) {
console.warn(`Failed to load prebuilt card ${file}:`, error);
}
}
});
// Merge static prebuilt templates
Object.entries(prebuiltTemplates).forEach(([key, tpl]) => {
// Basic guard to avoid bad entries
if ((tpl as any)?.agents && Array.isArray((tpl as any).agents)) {
templates[key] = tpl as z.infer<typeof WorkflowTemplate>;
}
} catch (error) {
console.warn('Failed to load prebuilt cards from directory:', error);
}
});
return templates;
}
export const templates: { [key: string]: z.infer<typeof WorkflowTemplate> } = loadTemplatesFromFiles();
export const templates: { [key: string]: z.infer<typeof WorkflowTemplate> } = buildTemplates();
// Note: Prebuilt cards are now loaded from app/lib/prebuilt-cards/ directory
// starting_copilot_prompts has been removed as it was unused

View file

@ -1,9 +1,11 @@
import { S3Client } from "@aws-sdk/client-s3";
export const uploadsS3Client = new S3Client({
region: process.env.UPLOADS_AWS_REGION || 'us-east-1',
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID || '',
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '',
},
});
region: process.env.RAG_UPLOADS_S3_REGION || process.env.AWS_REGION || 'us-east-1',
credentials: (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY)
? {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
}
: undefined as any,
});