Skip to content

feat: Production release 2025‑08‑18 — Admin console (chatflows & org credentials), chatflow versioning, settings API, stricter auth, Lacework ops, and release automation - #475

Merged
maxtechera merged 89 commits into
productionfrom
staging
Aug 18, 2025
Merged

Conversation

@ct3685

@ct3685 ct3685 commented Aug 14, 2025

Copy link
Copy Markdown

Title

feat: Production release 2025‑08‑18 — Admin console (chatflows & org credentials), chatflow versioning, settings API, stricter auth, Lacework ops, and release automation

Description

This release promotes the current staging state to production (2025‑08‑18). It introduces an Admin area (UI + API), organization‑level credential gating, chatflow versioning (with new DB columns & endpoints), a user/org settings API, stricter organization‑based authentication, optional Lacework sidecar integration for Fargate/Copilot deployments, and release automation (semantic‑release + CI). Motivation is inferred from the diff; no explicit issue references were found.

Highlights

  • Admin Console (UI + API)
    • New admin pages under apps/web/app/(Main UI)/sidekick-studio/(main-layout)/admin/ for Dashboard and Org Credentials; pages render @ui/Admin and @ui/OrgCredentials/OrgCredentialsManager and enforce admin role in SSR, returning an access‑denied message otherwise.
    • New server admin router adds endpoints for chatflows (list with field selection, default template, versioning list/rollback, bulk update) and organization credentials (get/update), all protected with enforceAbility.
    • Client API wrappers added for these admin endpoints: getAdminChatflows, getDefaultChatflowTemplate, bulkUpdateChatflows, getChatflowVersions, getChatflowVersion, rollbackChatflowToVersion, and org credential APIs getOrgCredentials / updateOrgCredentials.
  • Chatflow Versioning (+ predictions use published version)
    • DB: ChatFlow adds currentVersion int default 1 and s3Location text (migrations for Postgres, MySQL, MariaDB, SQLite).
    • API: Version endpoints under both admin and chatflows routes; also rollback.
    • Services: predictions/build path now resolves published chatflow via chatflowsService.getChatflowForPrediction (replacing direct repository calls); delete cleans up versioned storage via chatflowStorageService.deleteChatflowStorage.
  • Organization Credential Gating
    • Organization entity adds enabledIntegrations jsonb (+ Postgres migration).
    • Admin endpoints to get/update enabled integrations, with validation of credentialName, label, and enabled. :contentReference[oaicite:16]{index=16}
    • UI integrates org‑level filtering of credentials for non‑admins; admins see full list.
  • Settings API (Next.js)
    • New /app/api/settings/route.ts: GET returns { userSettings, orgSettings }; POST updates user.appSettings via Prisma; both require authenticated session.
  • Authentication Hardening
    • Middleware now derives permissions (adds org:manage for Admin role), and enforces allowed AUTH0_ORGANIZATION_ID list; unauthorized org yields 401.
    • UI: unauthenticated visits to /chat now redirect to login with a return URL. :contentReference[oaicite:21]{index=21}
  • Ops: Optional Lacework Sidecar for Copilot/Fargate
    • copilot/flowise/manifest.yml adds sidecar, depends_on, and taskdef_overrides to run the Lacework entrypoint script before starting the app; LaceworkVerbose surfaced.
    • New docs and README section detailing enable/disable, verification, and security notes. :contentReference[oaicite:25]{index=25}
  • Release Automation & Dependency Hygiene
    • New .releaserc.json targets the production branch with semantic‑release.
    • New CI workflow .github/workflows/release.yml triggers on push to production (plus a workflow_dispatch dry run).
    • .github/dependabot.yml revamped: daily npm checks to staging with minor/patch grouping and majors ignored; weekly GitHub Actions updates.

UI

  • Admin area
    • Admin landing: apps/web/app/(Main UI)/sidekick-studio/(main-layout)/admin/page.tsx renders @ui/Admin.
    • Org Credentials page restricts to Admin (SSR check), rendering OrgCredentialsManager.
    • Admin dashboard cards include links to Manage Chatflows (/admin/chatflows) and Org Credentials.
  • Credentials view
    • Adds org‑aware filtering controlled by Flagsmith (useFlags) and new /admin/organizations/credentials APIs.
  • Agentflows navigation
    • Canvas routing switches based on agentflowVersion === 'v2'.
  • Chat page access
    • Unauthenticated users are redirected to /api/auth/login?redirect_uri=/chat. :contentReference[oaicite:35]{index=35}

API

  • Next.js Settings
    • GET /api/settings: returns userSettings and orgSettings for the current user (via Prisma include).
    • POST /api/settings: updates user.appSettings. Both require session.
  • Admin routes (Express)
    • Chatflows: GET /admin/chatflows, GET /admin/chatflows/default-template, GET /admin/chatflows/:id/versions, PUT /admin/chatflows/bulk-update, POST /admin/chatflows/:id/rollback/:version.
    • Organizations: GET /admin/organizations/credentials, PUT /admin/organizations/credentials.
  • Chatflows routes (non-admin)
    • Adds GET /chatflows/:id/versions, GET /chatflows/:id/versions/:version, POST /chatflows/:id/rollback/:version.
  • Predictions/build
    • createPrediction and utilBuildChatflow now use chatflowsService.getChatflowForPrediction, with a comment noting it gets the published version for predictions.

Data

  • Entities
    • ChatFlow: adds currentVersion?: number (default 1), s3Location?: string.
    • Organization: adds enabledIntegrations?: string (jsonb).
  • Migrations (all supported DBs)
    • Postgres: add currentVersion + s3Location, and enabledIntegrations columns; registered in migration index.
    • MySQL/MariaDB/SQLite: parallel migrations for currentVersion + s3Location; indexes updated.

Auth & Security

  • Org‑based access control (server)
    • Middleware: builds permissions (e.g., org:manage for Admin) and validates user’s org against AUTH0_ORGANIZATION_ID list, rejecting mismatches with 401.
  • Admin‑only org credential updates (server)
    • Controller checks for authenticated Admin and existing organizationId prior to updates; returns appropriate errors otherwise.

Build/CI

  • Semantic‑release configured for the production branch with GitHub plugin; tags as v${version}.
  • CI workflow runs semantic‑release on push to production, with a manual dry‑run job.
  • Dependabot groups minor/patch updates and ignores majors; GitHub Actions weekly on Monday @ 09:00.
  • Gitignore additions**:** ignore .bwsconfig.cache in root and in scripts/bws-secure/.

Ops & Scripts

  • Lacework sidecar (Copilot manifest): defines sidecars.datacollector-sidecar, depends_on, and taskdef_overrides (entrypoint + volume mount).
  • Documentation & README for Lacework enable/disable and verification commands. :contentReference[oaicite:59]{index=59}
  • BWS Secure docs: additional envs like BWS_PROJECT_ID, BWS_NO_OVERRIDE, suppression flags; .bwsconfig.cache ignored.

Docs

  • Broad branding updates from “AnswerAI” → “AnswerAgentAI” across Docusaurus config, OpenAPI docs, and various pages; dark mode switch disabled (disableSwitch: true).
  • New/updated deployment docs (Azure/GCP), and PGVECTOR_SETUP.md with platform‑specific install guidance; the Postgres migration now logs next steps rather than failing when pgvector is absent.
  • Blog tags.yml extended (e.g., release, platform, ai-ethics, etc.).
  • Admin Chatflows docs include field selection guidance and performance notes. :contentReference[oaicite:68]{index=68}

Expected Impact

  • Admins can centrally manage chatflows (including versions/rollback) and control which integrations are available org‑wide. :contentReference[oaicite:70]{index=70}
  • Predictions/builds use the published chatflow version to improve stability.
  • End‑user routing to login for /chat avoids anonymous sessions in the main chat UI. :contentReference[oaicite:72]{index=72}
  • Optional Lacework integration improves runtime visibility without blocking the app if absent/misconfigured. :contentReference[oaicite:74]{index=74}

Breaking Changes / Risks

  • Auth tightening: Requests from users whose org is not in AUTH0_ORGANIZATION_ID will now get 401 Unauthorized. Ensure this env var lists all permitted org IDs.
  • /chat now requires login (redirect applied). If previous behavior allowed viewing without auth, this is a functional change. :contentReference[oaicite:76]{index=76}
  • DB schema changes: new columns on chat_flow and organization tables. Migrations must be applied before app start.

Migrations / Deployment Notes

  • Run the new migrations for your DB engine (Postgres/MySQL/MariaDB/SQLite) before deploying the new server build.
  • Postgres environments without pgvector will now see warnings with installation steps; the migration does not hard‑fail.

Environment / Config Changes

  • Auth: Confirm AUTH0_ORGANIZATION_ID (comma‑separated) includes your production org(s).
  • Ops (optional): To enable Lacework, set LaceworkAccessToken (and optionally LaceworkServerUrl, LaceworkConfig) in copilot.{env}.env; LaceworkVerbose defaults to true in manifest.
  • BWS Secure: new optional envs BWS_PROJECT_ID, BWS_NO_OVERRIDE, BWS_SUPPRESS_ALL, BWS_SUPPRESS_MISSING for local/CI ergonomics.

Testing Notes

  • Admin UI
    • Verify access control (Admin can see Dashboard and Org Credentials; non‑Admin sees access denied).
    • From Dashboard, follow cards to /admin/chatflows and /admin/org-credentials.
  • Org Credentials
    • GET /admin/organizations/credentials returns current enabled integrations.
    • PUT /admin/organizations/credentials enforces validation; confirm changes affect non‑Admin credential visibility in UI.
  • Versioning
    • Create multiple versions, list via GET /admin/chatflows/:id/versions, retrieve a specific version via /chatflows/:id/versions/:version, and test rollback.
  • Predictions
    • Confirm predictions/build use the published version with getChatflowForPrediction.
  • Settings API
    • Authenticated GET/POST /api/settings returns/updates user.appSettings (and includes orgSettings on GET).
  • Auth flows
    • Attempt /chat unauthenticated → expect redirect to login with redirect_uri=/chat. :contentReference[oaicite:97]{index=97}
  • Ops
    • With Lacework token set, verify sidecar processes/logs and that the main app still runs if the sidecar is absent.

No new external issue references were found in the diff. If anything above is unclear, it is because the motivation is not explicitly evident from the code changes alone.

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>
…ct ID support, and minimal config refresh throttling (#488)

## Title
feat: add BWS configuration controls, suppression flags, direct project
ID support, and minimal config refresh throttling

## Description
This update significantly enhances Bitwarden Secrets (BWS) integration
by introducing new environment variables, improving configuration
handling, and adding granular control over output. It also introduces
minimal throttling for configuration updates to keep `.env` and
`bwsconfig.json` accurate without overloading the update process.

### Documentation (`README.md`)
- Added new environment variables:
- **`BWS_PROJECT_ID`** — Directly specify a BWS project UUID to bypass
project selection.
- **`BWS_NO_OVERRIDE`** — Prevent automatic refresh of `bwsconfig.json`
from BWS secrets.
- **`BWS_SUPPRESS_ALL`** — Suppress all secure-run logging while
preserving wrapped command output (errors always shown).
- **`BWS_SUPPRESS_MISSING`** — Suppress missing environment variable
warnings during validation.
- Included practical examples for local development and CI/CD usage.

### Git Ignore & Installation (`.gitignore`, `install.sh`)
- Added `.bwsconfig.cache` to `.gitignore` to exclude the config refresh
marker file.
- Updated `install.sh`:
  - Ensures `.bwsconfig.cache` is ignored by default.
- Chooses `yargs` and `glob` dependency versions dynamically based on
Node.js version.
  - Improved inline comments for clarity.

### Environment Validation (`env_validator.js`)
- Added `BWS_SUPPRESS_MISSING` support to optionally silence missing
variable logs.
- Adjusted warning logic to respect suppression settings without
affecting build continuation.

### Project Selection Logic (`project-selector.js`)
- Handles missing or empty project configurations:
- Logs instructions to use `BWS_PROJECT_ID` when no projects are
available.
  - Throws a descriptive error when configuration is empty.
- Improved invalid project detection:
  - Warns when a configured project no longer exists.
- Avoids unnecessary `.env` updates if the existing project is still
valid.

### Secure Run Enhancements (`secureRun.js`)
- **Global Suppression Mode (`BWS_SUPPRESS_ALL`)**
  - Mutes all secure-run console output except errors.
  - Applies suppression to child process `stdio` as well.
- **Direct Project ID Bypass (`BWS_PROJECT_ID`)**
- Loads and decrypts secrets directly for the given UUID, skipping
config file and selection logic.
- Requires only `BWS_ACCESS_TOKEN` and `BWS_PROJECT_ID` to function —
ideal for CI/CD pipelines.
- Avoids downloading the full configuration unless explicitly required,
making it possible to operate without a `bwsconfig.json` file in some
workflows.
- **Configuration Override Control (`BWS_NO_OVERRIDE`)**
- Skips Bitwarden config refresh entirely, relying only on local
`bwsconfig.json`.
- **Minimal Config Refresh Throttling (`.bwsconfig.cache`)**
  - Adds a 5-minute refresh window for `_bwsconfig_json`-based updates.
- Prevents redundant config pulls that could repeatedly rewrite `.env`
while ensuring updates are applied when `_bwsconfig_json` changes.
- Not a secrets cache — it only tracks the last refresh time to avoid
unnecessary API calls.
- **Enhanced Config Merge Logic**
- Merges multiple `_bwsconfig_json` secrets into a unified
configuration, combining project IDs when overlaps exist.
- Writes merged configuration to `bwsconfig.json` and updates the
refresh marker file.
- **Resilient Project Matching**
- If `BWS_PROJECT` does not match any configured project, automatically
switches to the first available and updates `.env`.
  - Only fails when no projects exist at all.

### Expected Impact
- **Developer Productivity**  
- Faster, more predictable startup by skipping unnecessary prompts and
refreshes.
- **CI/CD Stability**  
- Minimal refresh throttling avoids `.env` churn while still applying
new `_bwsconfig_json` updates promptly.
  - Cleaner logs with suppression flags.
- **Configuration Accuracy**  
- Ensures local `.env` and `bwsconfig.json` stay in sync with BWS
secrets.
- **Resilience**  
  - Auto-recovery for invalid or missing project references.
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cameron Taylor <50385537+ct3685@users.noreply.github.com>
#478)

… cost calculator, and usage events

## Overview
This commit introduces a new billing page in the main UI, enhancing the
user experience with dynamic loading of key components.

## Changes Made
- Created a new billing page at `apps/web/app/(Main
UI)/billing/page.tsx`
- Integrated dynamic imports for:
  - BillingDashboard
  - CostCalculator
  - UsageEventsTable

## Impact
- Provides a centralized billing interface for users, improving
accessibility to billing-related features.
- Utilizes dynamic imports to optimize performance by loading components
only when needed.

---------

Co-authored-by: Cameron Taylor <50385537+ct3685@users.noreply.github.com>
…HA weekly (#489)

chore(dependabot): schedule w/ timezone, group minor+patch, ignore
majors; make GHA weekly

**What changed**
- **npm (root `/`)**
  - Runs **daily at 09:00**.
  - **Ignores semver major** updates by default.
- Adds a **`npm-minor-patch` group** to bundle **minor + patch** bumps
into a single PR when possible.
  - Keeps `target-branch: staging` and `open-pull-requests-limit: 10`.

- **GitHub Actions (root `/`)**
  - Moves schedule to **weekly on Monday at 09:00**.
  - **Ignores semver major** updates by default.
- Adds a **`gha-minor-patch` group** to bundle **minor + patch** bumps.
  - Keeps `target-branch: staging` and `open-pull-requests-limit: 10`.

- **Docs/structure**
  - Clarifies that pnpm users still use the `"npm"` ecosystem.
  - Adds inline comments and normalizes YAML formatting/quoting.
- Provides a **commented-out template** for routing **major npm
updates** to a separate branch (`release/majors`) on a **monthly**
cadence (only majors allowed).

**Why**
- Reduce update noise by grouping safe changes, while **preventing
automatic major bumps**.
- Make updates more predictable with explicit **time + timezone**.
- Slow down GitHub Actions dependency churn to a **weekly** cadence.
- Added JSON -LD
- Updated references to AnswerAI to be AnswerAgentAI
maxtechera
maxtechera previously approved these changes Aug 18, 2025

@maxtechera maxtechera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread packages-answers/ui/src/AppLayout/AppLayout.Client.tsx
Comment thread packages-answers/ui/src/Apps/Apps.Client.tsx
Comment thread packages/server/src/services/chatflows/index.ts
… `production` + manual dry-run) (#491)

Github Release
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
3.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@ct3685 ct3685 changed the title Next Staging Release - TBD feat: Production release 2025‑08‑18 — Admin console (chatflows & org credentials), chatflow versioning, settings API, stricter auth, Lacework ops, and release automation Aug 18, 2025

@maxtechera maxtechera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@maxtechera
maxtechera merged commit f1be198 into production Aug 18, 2025
7 of 10 checks passed
@maxtechera
maxtechera temporarily deployed to staging - theanswer-iek0 August 18, 2025 18:24 — 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.

6 participants