Skip to content

[ Release 2025-08-09 ] feat(docs+infra): migrate to API_HOST, add submodule workflows, bump pnpm to 9.15.9; refresh MCP chatflows; remove legacy CSV script - #463

Merged
ct3685 merged 77 commits into
productionfrom
staging
Aug 9, 2025
Merged

[ Release 2025-08-09 ] feat(docs+infra): migrate to API_HOST, add submodule workflows, bump pnpm to 9.15.9; refresh MCP chatflows; remove legacy CSV script#463
ct3685 merged 77 commits into
productionfrom
staging

Conversation

@ct3685

@ct3685 ct3685 commented Aug 9, 2025

Copy link
Copy Markdown

[ Release 2025-08-09 ] feat(docs+infra): migrate to API_HOST, add submodule workflows, bump pnpm to 9.15.9; refresh MCP chatflows; remove legacy CSV script

Summary

Standardizes environment/config around API_HOST (deprecating API_BASE_URL), formalizes Git submodule management & scripts, updates pnpm to 9.15.9, refreshes default MCP chatflows/metadata, and removes an unused CSV processing script. Includes security/compatibility dependency overrides.

Changes

CI / Tooling

  • GitHub Actions: pnpm 9.7.09.15.9 in .github/workflows/main.yml.
  • package.json:
    • packageManager: pnpm@9.15.9.
    • New scripts:
      • submodule:initgit submodule update --init --recursive --force
      • submodule:resetgit submodule deinit -f --all && git submodule update --init --recursive
    • Seed credentials:
      • seed-credentials now uses --test --auto-detect
      • seed-credentials:write adds --auto-detect
    • Removes scripts:processCsvRows.
    • Dependency overrides tightened/added for security/compat (e.g. axios@1.8.2, express>=4.19.2, esbuild>=0.25.0, postcss>=8.4.31, micromatch>=4.0.8, send>=0.19.0, serve-static>=1.16.0, cookie>=0.7.0, tmp^0.2.4, webpack-dev-server>=5.2.1, etc.).

Code

  • AnswerAgent MCP (AnswerAgentMCP.ts):
    • Reads API host from options.user?.chatflowDomain (instead of process.env.API_HOST).
    • Passes ANSWERAGENT_AI_API_HOST (replaces ANSWERAGENT_AI_API_BASE_URL usage).
    • Improves API key retrieval fallback (uses DB ApiKey via databaseEntities).
  • AAIPostgres: minor cleanup (whitespace).

Docs

  • CONTRIBUTING.md: major new section on Git submodules—setup, daily workflow, troubleshooting, best practices, and merge strategy (squash-and-merge by default).
  • README.md:
    • Recommends cloning with --recursive.
    • Adds submodule verification/reset via new pnpm scripts.
    • Deprecates API_BASE_URL; use API_HOST (notes /api/v1 is implied by server).
  • Salesforce OAuth docs (both developer + personal): replace API_BASE_URL with API_HOST and update troubleshooting accordingly.
  • AnswerAgent MCP docs: formatting/consistency improvements and API_HOST guidance.

Submodules

  • packages/embed submodule updated to commit d155b893….

Marketplaces / Chatflows

  • Default Sidekick chatflows for AnswerAgent MCP, BraveSearch, Confluence, Contentful, and Jira:
    • Renamed to “Default … MCP Sidekick”, added stable ids.
    • Added visibility, category, type, and chatbotConfig (starter prompts, upload config).
    • Updated system/human prompts for clarity and consistent injected context blocks.

Removals

  • Deleted packages-answers/scripts/processCsvRows.ts (unused/legacy).

Migration Notes (⚠️)

  • Environment: Replace any use of API_BASE_URL with API_HOST across .env and integrations.
  • AnswerAgent MCP: External tooling/env that previously read ANSWERAGENT_AI_API_BASE_URL should now use ANSWERAGENT_AI_API_HOST (this repo now passes the HOST variant).
  • Submodules: After pulling, run:
    pnpm submodule:init   # or pnpm submodule:reset if things look off

bradtaylorsf and others added 30 commits July 16, 2025 09:57
- Fix JSX element return in homepage component
- Remove path restriction from redirect hook
- Add timeout protection and enhanced error handling
- Ensure all error scenarios fallback to /chat

Resolves AAI-489
- Fix JSX element return in homepage component
- Remove path restriction from redirect hook
- Add timeout protection and enhanced error handling
- Update related page components for consistency
- Ensure all error scenarios fallback to /chat

Resolves AAI-489
…edirect-handler-not-working-properly

Aai 489 bug homepage chat redirect handler not working properly
- Enhance clarity and structure of local development instructions
- Add steps for cloning the repository, setting up environment variables, initializing git submodules, and running the application
- Include optional steps for faster startup and database tool installation
- Add step for installing Docker Desktop and ensuring it is running
- Reorder steps for clarity, including building and migrating the initial database
- Update instructions for running the application and accessing it
- Enhance guidance for development with fast reload instructions
…me-updates

docs: update README for local development setup
…rovements

This comprehensive update addresses GitHub issue #391 and Jira ticket AAI-487 by implementing multi-tenant template management with proper organization scoping and critical security fixes.

## 🆕 New Features

### Multi-Tenant Template System
- **Organization Scoping**: Templates now belong to specific organizations
- **Template Sharing**: Option to share templates within organization
- **Template Lineage**: Track parent-child relationships and template origins
- **Answer Agent Framework**: Added support for Answer Agent framework detection

### Enhanced UI Experience
- **Organization Templates Tab**: New tab showing organization-shared templates
- **Template Segregation**: Answer Agent templates filtered from Example Templates
- **Share Toggle**: UI option to share templates with organization members
- **Improved Template Export**: Better framework detection and metadata handling

## 🔧 Database Schema Updates

### New Migrations
- `AddOrganizationToCustomTemplate`: Adds organization and user scoping
- `AddParentIdToCustomTemplate`: Enables template lineage tracking
- `AddTemplateIdToChatFlow`: Links chatflows to their template origins

### Enhanced Entities
- **CustomTemplate**: Added userId, organizationId, shareWithOrg, parentId fields
- **ChatFlow**: Added templateId field for template tracking
- **Soft Delete**: Implemented for data integrity and audit trails

## 🛡️ Critical Security Fixes

### Authentication & Authorization
- **Mandatory Authentication**: All marketplace endpoints now require authentication
- **Ownership Validation**: Proper user/organization ownership checks
- **Permission System**: Role-based access control for templates

### Chatflow Deletion Security
- **Authorization Logic**: Fixed flawed permission checking in deleteChatflow
- **Route Security**: Removed vulnerable DELETE pattern allowing deletion without ID
- **Transaction Safety**: Wrapped deletion operations in database transactions

### Migration Resilience
- **No-Organization Handling**: Migration handles environments without organizations
- **System Templates**: Orphaned templates become system-wide instead of failing

## 🎯 API Improvements

### New Endpoints
- `GET /marketplaces/organization`: Retrieve organization-shared templates
- Enhanced marketplace endpoints with proper authentication middleware

### Enhanced Services
- **Template Service**: Improved filtering, validation, and framework detection
- **Chatflow Service**: Better authorization and cleanup procedures
- **Error Handling**: Consistent error responses and proper status codes

## 📊 Frontend Enhancements

### Template Management
- **Filtered Views**: Answer Agent templates excluded from Example Templates
- **Organization Tab**: Dedicated view for organization-shared templates
- **Enhanced Metadata**: Better template information display and searching

### User Experience
- **Template Sharing**: Easy organization sharing toggle
- **Framework Detection**: Automatic framework classification
- **Improved Navigation**: Better template organization and discovery

## 🔍 Technical Details

### Framework Detection
- Automatic detection of Answer Agent templates based on MCP Tools usage
- Enhanced framework categorization (Langchain, LlamaIndex, Answer Agent)
- Better template metadata extraction and processing

### Data Integrity
- Soft delete implementation across all related entities
- Proper cleanup of chatflow dependencies (messages, feedback, history)
- Transaction-safe operations with rollback capabilities

### Performance Optimizations
- Efficient query patterns with proper indexing
- Optimized filtering and search operations
- Reduced database roundtrips through better query design

## 🚀 New MCP Sidekick Templates
- Answer Agent MCP Sidekick
- BraveSearch MCP Sidekick
- Confluence MCP Sidekick
- Contentful MCP Sidekick
- Jira MCP Sidekick
- PostgreSQL MCP Sidekick
- Salesforce MCP Sidekick
- Slack MCP Sidekick
- YouTube MCP Sidekick

Fixes: #391
Jira: AAI-487
- Fixed orphaned object literals after commented console.log statements
- Properly commented out object properties in MarketplaceCanvas.jsx
- Properly commented out object properties in MarketplaceLanding.jsx
- Properly commented out object properties in canvas/index.jsx
- Resolves build errors while preserving debug information for future use
- Removed the `update_ui_env.sh` script from the Dockerfile as it is no longer needed for application startup.
- Updated the ENTRYPOINT to use the default CMD for starting the application.
- Changed the DBClusterParameterGroup Family from 'aurora-postgresql14' to 'aurora-postgresql16'.
- Updated the EngineVersion from '14.4' to '16.9' for compatibility with the latest features.
…coping-and-security

feat: implement organization-scoped custom templates
Fix Sidekicks Loading Issues and Enhance UI Navigation
…anization (#413)

* feat: move pgvector scripts to AAIPostgres package for better organization

* fix: update script references in AAIPostgres component to use new package location

* fix: update pgvector script references in server migration to use new package location

* chore: update tsconfig to include AAIPostgres scripts in compilation

* chore: remove old root-level pgvector scripts and documentation
replaced API_BASE_URL with API_HOST in passport
* error handling in salesforce route

* some better logging

---------

Co-authored-by: Jaime Morales <jaime@lastrev.com>
ct3685 and others added 19 commits August 5, 2025 23:46
…roved compatibility and performance

- Add postcss@8.4.31, tsup@8.3.5, and jsforce@3.10.0 to package.json for enhanced functionality
- Remove react-scripts from packages/ui/package.json to streamline dependencies
- Upgrade tsup in packages-answers/ui/package.json to version 8.3.5 for better build performance
- Modify pnpm-lock.yaml to reflect updated dependency versions for consistency and stability
…roved functionality

- Refactor BWS Secure scripts to utilize execBwsCommandWithRetrySync for better error handling and retry logic
- Update README.md for clearer instructions on creating access tokens
- Upgrade dotenv, dotenv-cli, yargs, and axios in package.json for compatibility and performance improvements
- Add bws-retry-utils.js for managing rate limits and retry logic in BWS commands
- Ensure consistent logging and error handling across BWS Secure scripts
- Change 'as' to 'AS' for consistency in stage definitions
- Ensure clarity in multi-stage build process by standardizing syntax
- Change submodule branch from ct/staging-pnpm-recursive-updates to a-main
- Update subproject commit reference for improved stability
- Add synchronous sleep function in bws-retry-utils.js for improved rate limit handling
- Upgrade actions/checkout from v3 to v4 for enhanced functionality
- Set fetch-depth to 0 for complete history retrieval during checkout
- Delete the SonarCloud analysis workflow file, running CI analysis with Automatic Analysis.
- Change 'AS' to 'as' for consistency in stage definitions
- Improve clarity in multi-stage build process by standardizing syntax
- Remove 'path-to-regexp: "0.1.12"' from pnpm.overrides in package.json
- This was forcing @oclif/core@4.0.7 to use old path-to-regexp version without .match() method
- Fixes 'pathRegexp.match is not a function' error that prevented CLI command registration
- CLI now properly discovers start/worker commands when environment variables are provided
- Revert multer-cloud-storage back to ^4.1.0 (was incorrectly blamed for the issue)
- Deployment should now work as CLI commands are properly discoverable
…otentially

security: upgrade dependencies to eliminate known vulnerabilities across monorepo
…mplate-metadata

Fix/aai 502 mcp sidekick template metadata
…anager (#458)

* fix: resolve tmp package vulnerability in Salesforce MCP dependencies

- Add tmp@^0.2.4 override to fix CVE in @answerai/salesforce-mcp and @tsmztech/mcp-server-salesforce
- Update packageManager to pnpm@9.14.4 (latest stable 9.x)
- Resolves low severity vulnerability: tmp allows arbitrary file/directory write via symbolic link
- Maintains alphabetical order in pnpm overrides section

Security audit now shows zero vulnerabilities.

* chore: update GitHub workflow to use pnpm@9.14.4 for consistency

* chore: update embed submodule to include clipboard markdown preservation fixes
## �� Enhanced Seed Credentials Script

### ✨ New Features

**Smart Auto-Detection for Local Development:**
- Automatically detects single user + single organization scenarios
- Offers to use auto-detected values with confirmation prompt
- Falls back to manual selection if declined
- Updates .env file with selected values for future use

**Intelligent Postgres Credential Grouping:**
- Groups related Postgres variables into meaningful configurations
- Reduces from 25+ generic "Postgres - AAI - Default" entries to 3
specific ones:
  - `Postgres Recordmanager - AAI - Default`
  - `Postgres Agentmemory - AAI - Default` 
  - `Postgres Vectorstore - AAI - Default`
- Proper field mapping for database, host, user, password, port,
tableName, etc.

**Streamlined User Experience:**
- Combined prompting for user and organization IDs (no more double
prompts)
- Always displays .env entries for easy copying
- Updated production mode message to use `pnpm seed-credentials:write`
- Absolute path display for .env file updates

### 🔧 Technical Improvements

**Code Quality:**
- Added ESLint disable comments for expected complexity in local
development script
- Added JSDoc comments for main functions
- Fixed async Promise executor patterns
- Proper error handling and fallback logic

**Documentation:**
- Updated README.md with auto-detection as default behavior
- Added comprehensive examples and usage instructions
- Documented new command-line options and environment variables

### 🎯 Impact

- **Local Development**: Much smoother experience with auto-detection
- **Credential Management**: Cleaner, more meaningful credential names
- **Maintainability**: Better code organization and documentation
- **User Experience**: Reduced prompts and clearer output

### �� Files Changed

- `scripts/seed-credentials/seed-credentials.js` - Core auto-detection
logic
- `scripts/seed-credentials/README.md` - Updated documentation  
- `package.json` - Updated scripts with auto-detection by default

### 🧪 Testing

The script has been tested and works correctly with:
- Single user/org auto-detection ✅
- Postgres variable grouping ✅
- Combined prompting ✅
- .env file updates ✅
- Fallback to manual selection ✅
#457)

## Summary

This PR addresses the issue reported in
[SUPPORT-4862](https://lastrev.atlassian.net/browse/SUPPORT-4862) by
removing a hardcoded script that was causing problems and cleaning up
unnecessary references.

## Changes Made

### 🗑️ Removed Files
- **`packages-answers/scripts/processCsvRows.ts`** (227 lines removed)
  - Contained hardcoded URL
- Was a duplicate implementation of functionality already present in the
server
- Had TODO comment indicating the hardcoding issue: `// TODO: use
chatflowChatId instead of hardcoded id`

### �� Updated Files
- **`package.json`** (1 line removed)
- Removed script reference: `"scripts:processCsvRows": "pnpm secure-run
\"ts-node ./packages-answers/scripts/processCsvRows.ts\""`

## Problem Solved

The removed script had several issues:
1. **Hardcoded URL**: Used a specific production URL instead of dynamic
configuration
2. **Code Duplication**: Duplicated functionality already implemented in
`packages/server/src/jobs/processCsvRows.ts`
3. **Architecture Violation**: Didn't follow project patterns for
logging, error handling, and database integration
4. **Maintenance Burden**: Required maintaining two implementations of
the same functionality

## Impact

- ✅ **Positive**: Eliminated code duplication and hardcoded values
- ✅ **Positive**: Improved code maintainability and consistency
- ✅ **Positive**: Consolidated CSV processing functionality in the
correct server implementation
- ✅ **Positive**: Removed potential source of confusion and bugs

## Verification

- The correct implementation in
`packages/server/src/jobs/processCsvRows.ts` remains intact
- Cron job functionality in `packages/server/src/utils/cron.ts`
continues to work properly
- No broken references remain in the codebase
- CSV processing functionality is preserved through the server
implementation

## Testing

- [x] Verified no remaining references to the deleted script
- [x] Confirmed server implementation is working correctly
- [x] Checked that cron jobs are properly configured
- [x] Validated that CSV processing functionality is intact

## Related

- **Ticket**:
[SUPPORT-4862](https://lastrev.atlassian.net/browse/SUPPORT-4862)
- **Type**: Bug fix / Code cleanup
- **Breaking Changes**: None

[SUPPORT-4862]:
https://lastrev.atlassian.net/browse/SUPPORT-4862?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[SUPPORT-4862]:
https://lastrev.atlassian.net/browse/SUPPORT-4862?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Co-authored-by: Cameron Taylor <cameron@lastrev.com>
### Summary

Deprecate `API_BASE_URL` in favor of `API_HOST` throughout the codebase
and documentation.

This PR refactors **TheAnswer's** environment variable usage and
associated documentation to use the single, canonical `API_HOST`
variable for API host configuration, fully deprecating the old
`API_BASE_URL`.

---

### 🛠️ Changes

## Code Refactor
- Replaces all uses of `API_BASE_URL` with `API_HOST` in environment
variable reads, process calls, and cron jobs.
- Removes fallback logic and references to `API_BASE_URL`.

## Documentation Updates
- Updates code samples, setup guides, OAuth integrations, and
troubleshooting docs (e.g., `README.md`, tools, server, OAuth docs) to
use only `API_HOST`.
- Adds migration warnings and notes to highlight deprecation of
`API_BASE_URL`.
- Clarifies best practices and configuration steps for API host usage in
both platform and external integration docs.

## Migration Instructions
- `API_BASE_URL` is **deprecated and unsupported**.
- Users must update their `.env` and deployment configurations to use
`API_HOST`.

## Various Minor Improvements
- Improves clarity in setup, troubleshooting, and configuration guidance
across user-facing content.

---

### ✅ Impact

- **All deployments and local setups** must now use `API_HOST` to
specify the API server.
- **OAuth flows, Salesforce integrations, and MCP tool setups** are
updated for consistency and clarity.
- ❌ No backwards compatibility — `API_BASE_URL` is removed entirely.

---

---------

Co-authored-by: Adam Harris <adam@lastrev.com>
### Summary

This commit introduces a helper function to retrieve the project ID with a fallback mechanism for environments lacking a specific project ID. The function checks for available project IDs and logs a message when a fallback is used.

### Changes Made

- Added `getProjectIdWithFallback` function to handle project ID retrieval with fallback logic.
- Updated `setupEnvironment` to utilize the new helper function for improved project ID handling.
- Enhanced logging for scenarios where a fallback project ID is used.

### Impact

- Improves robustness in project ID management, ensuring that environments without a specific project ID can still function correctly by falling back to the first available ID.
- Provides clearer logging for better debugging and monitoring of environment setups.
@ct3685 ct3685 self-assigned this Aug 9, 2025
@vercel

vercel Bot commented Aug 9, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
answerai-docs ✅ Ready (Inspect) Visit Preview Aug 9, 2025 4:35pm
the-answerai ✅ Ready (Inspect) Visit Preview Aug 9, 2025 4:35pm

@ct3685 ct3685 changed the title [ Release 2025-08-09 ] [ Release 2025-08-09 ] feat(docs+infra): migrate to API_HOST, add submodule workflows, bump pnpm to 9.15.9; refresh MCP chatflows; remove legacy CSV script Aug 9, 2025
@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@ct3685
ct3685 merged commit 630598c into production Aug 9, 2025
18 of 20 checks passed
@maxtechera
maxtechera temporarily deployed to staging - theanswer-iek0 August 9, 2025 17:38 — with Render Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants