fix: Enable incident graph correlation with anti-spam protection - #548
fix: Enable incident graph correlation with anti-spam protection#548emooreatx wants to merge 63 commits into
Conversation
This commit adds Android app packaging for CIRIS with: - Chaquopy Python integration for embedded ciris_engine - WebView-based GUI using Next.js static export - Google Sign-In and Google Play Billing integration - CIRISProxy LLM client for API-backed inference - Separate android_gui_static folder for Android assets Key features: - Native Android app with Material Design UI - Dual authentication (Google Sign-In + API key) - In-app credit purchases via Google Play - Embedded Python runtime for local processing - WebView for GUI with native auth injection 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update mobile_main.py to use CIRISRuntime like desktop version - Start all 22 services, buses, and agent processor - Add scrolling console view during startup showing Python logs - Capture Python stdout/stderr from logcat and display in real-time - Show status indicator (Starting → Ready/Error) - Auto-scroll console as new log lines appear - Transition to WebView once health check passes This fixes the "Runtime not available" error during first-run setup by ensuring the full runtime is initialized before setup completion. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add pre-built CIRIS GUI static assets for Android WebView - Fix QA runner server error detection (read from console log instead of stderr) - Fix path_resolution.py to check ciris_engine subdirectory for templates - Update tests with **kwargs for mock compatibility - Exclude large media files (images/videos) to keep repo size manageable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Check OPENAI_API_BASE for llm.ciris.ai before enabling billing - On Android without Google ID token but not using proxy, use SimpleCreditProvider - On Android using proxy without token, warn and use SimpleCreditProvider - Prevents 401 errors when billing is enabled but no valid credentials exist 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Major new feature: Android on-device packaging with embedded WebView GUI 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
JWT auth with Google ID token should ONLY be used when using the CIRIS LLM proxy (llm.ciris.ai). Server deployments on ciris.ai use API key auth. Updated condition: google_id_token AND using_ciris_proxy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Mypy fixes (5 errors → 0): - Remove unused type: ignore comments (docx2txt, ntplib, psycopg2) - Fix default_factory type mismatch in MetricDataPoint.tags Billing auth logic rewrite: - Server: API key auth when CIRIS_BILLING_API_KEY set - Android + CIRIS proxy: JWT auth with Google ID token - Android + no proxy: No billing (local LLM) - Remove SimpleCreditProvider (never used) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Restore type: ignore comments for optional imports (docx2txt, ntplib, psycopg2) - Use blanket type: ignore for complex decorator pattern in retry.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Restrict cleartext traffic to localhost - Use EncryptedSharedPreferences for API keys - Enable minification and resource shrinking for release builds - Harden WebView configuration (disable file access, restrict navigation) - Inject configuration from secure settings into Python runtime
- Add billing_mode field to CreditContext (transactional/informational)
- Android uses informational mode (check only, billing via LLM proxy)
- Hosted sites use transactional mode (check + spend per interaction)
- Support CIRIS proxy as secondary LLM with JWT auth
- Fix Android setup status parsing (unwrap SuccessResponse)
- Fix test expectation for Optional tags field (None vs {})
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Merging Android Interact UI with Native/Web Toggle
Only intercept GUI runtime page URLs, not API endpoints like /v1/system/runtime/reasoning-stream which are used by SSE consumers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Set NoActionBar theme for InteractActivity to fix crash caused by theme/toolbar conflict (activity used custom Toolbar with theme that already provided ActionBar) - Simplify android version.py to static version (removes 99% duplication) - Original file-hashing logic doesn't work in Android package context - Git commands unavailable, wrong directory structure - Native Interact UI now renders correctly with WebView toggle preserved 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix .coveragerc to use ./setup.py instead of setup.py to avoid excluding routes/setup.py from coverage - Refactor complete_setup() by extracting _validate_setup_passwords() and _save_and_reload_config() helpers to reduce cognitive complexity - Refactor _initialize_llm_services() by extracting _get_llm_service_config_value() helper to reduce cognitive complexity - Fix f-string issues in mobile_main.py and resource_monitor service - Add comprehensive tests for new helper functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…sets - Login page: Changed "BYOK" to "Local Login" with info text - Added explanation: CIRIS hosted LLM requires Google login - Restored full Stripe-integrated billing page - Rebuilt GUI static assets with billing functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Privacy Policy Updates: - Comprehensive privacy-by-design documentation - Clear explanation of on-device data processing - CIRIS proxy stateless architecture explained - Data collection limited to: login, payment, optional marketing - Third-party LLM provider disclosures - GDPR/DSAR compliance information Marketing Opt-In: - Added checkbox to login screen for Google Sign-In users - Optional marketing communications consent - Privacy policy link in login UI - Marketing preference passed to MainActivity 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add 14 new tests for Android mobile_main.py entrypoint achieving 100% coverage - Tests for setup_android_environment() directory creation and env loading - Tests for start_mobile_runtime() lifecycle and error handling - Tests for main() function and keyboard interrupt handling - Tests for environment variable defaults and offline mode - Add 8 new tests for resource_monitor/service.py improving coverage to 90% - Tests for check_credit/spend_credit without provider errors - Tests for SHUTDOWN action signal emission - Tests for unknown resource type handling - Tests for token refresh signal detection and processing - Tests for PostgreSQL connection string handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive tests for: - Logout endpoint (API key revocation) - Get current user endpoint (/auth/me) - Refresh token with no auth - OAuth provider endpoints (list, configure) - OAuth login for GitHub, Discord, unsupported providers - GitHub/Discord OAuth error handling - First user detection and role determination - Profile storage with picture validation - OAuth frontend URL redirect - Marketing opt-in parsing - OAuth callbacks for all providers - Native Google ID token exchange - API key management (create, list, delete) - Google OAuth user info error handling All 81 tests pass with 96.86% coverage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add CIRIS_BILLING_GOOGLE_ID_TOKEN to .env when CIRIS LLM proxy selected in setup wizard (wizard.py) - Update TokenRefreshManager.kt to refresh billing token alongside API key - Fix DialectAdapter race condition in authentication_store.py that caused parallel tests to fail with "no such table: information_schema.columns" when SQLite connection used global PostgreSQL adapter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Python.start() can block the main thread for several seconds during startup, triggering Android's "App Not Responding" dialog. Move the initialization to a coroutine on Dispatchers.Default to keep the UI thread responsive while showing the loading console. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add robust token refresh handling to LLM service with circuit breaker reset - Fix billing routes to support Android/JWT mode (no API key required) - Update billing provider with better 401 error handling and token refresh signals - Reinitialize billing provider after first-run setup completes - Change instructor mode to JSON for Maverick (native structured output) - Update comprehensive guide: 3 providers (Together.ai, Groq, OpenRouter), all using Llama 4 Maverick with Zero Data Retention (ZDR) - Fix tests for new billing JWT mode and LLM service task_id requirement 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Template is ONLY used to seed identity and tickets config on first run - After seeding, ALL config comes from graph - template is ignored entirely - Tickets config now stored in graph and retrieved by tickets.py - Add CIRIS_TEMPLATE env var support in config bootstrap - Add pre-1.7.0 compatibility: default DSAR SOPs added for existing agents - Update tickets.py helpers to be async and read from config_service - Update comprehensive guide: 3 LLM providers with ZDR, all using Maverick 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add 8 tests covering tickets config migration scenarios - Test no service_initializer/config_service cases - Test existing config skip, template migration, default DSAR SOPs - Test error handling for get_config and set_config failures - Coverage improved from 47.3% to 50.1% for ciris_runtime.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add 14 new tests for billing provider edge cases - Test JWT auth mode, token refresh callback, 401/402/409 responses - Test request errors, spend errors, unexpected status codes - Coverage improved from 61% to 88% for ciris_billing_provider.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- First OAuth user (SYSTEM_ADMIN) now auto-minted as ROOT WA on login - Existing SYSTEM_ADMIN users also auto-minted on subsequent logins if not already minted - Setup wizard now creates users with ROOT role instead of AUTHORITY - This allows setup users to handle deferrals without manual minting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix first-run identity seeding: delay until setup wizard completes - Add CIRIS_TEMPLATE env var support for template selection - Implement resume_from_first_run() for proper service initialization - Update targetSdk to 35 for Play Store compliance - Add Play Integrity API dependency for device attestation - Add debug symbols (FULL) for crash analysis - Configure Gradle signing for release builds - Update GUI static assets from CIRISGUI-Android - Fix mypy type error in identity manager initialization - Update tests for new resume_from_first_run behavior Version: 1.6.7.4 (versionCode 7) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add PlayIntegrityManager for device/app attestation via billing.ciris.ai - Integrate integrity checks at app launch and JWT token refresh - Update ABI filters to include both x86_64 (emulator) and arm64-v8a - Fix backup_rules.xml lint error (add include before exclude) - Fix mypy unused type-ignore comments - Bump version to 1.6.8 (code 8) Note: ARM64 pydantic-core wheel must be built locally (too large for git). Build with: /tmp/build_pydantic_arm64.sh 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Script to build pydantic-core wheels for all Android architectures: - x86_64 (emulator) - arm64-v8a (modern devices like Samsung) - Optional: armeabi-v7a, x86 (older devices) Usage: ./android/scripts/build-pydantic-wheels.sh 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Downgrade from Python 3.12 to 3.10 for armeabi-v7a compatibility - Build pydantic_core cp310 wheels for all architectures (x86_64, arm64-v8a, armeabi-v7a) - Update Gradle task to copy pydantic_core Python sources to armeabi-v7a - Update wheel build script for Python 3.10 with per-target pointer_width - Version bump to 1.6.11 (build code 11) - Includes service startup logging improvements (Service X of 22 format) - Auth debug logging and mypy type fixes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- auth.py: Add proper type annotations for Dict[str, Any] and Set[str] - auth.py: Fix allowed_audiences to handle None client_id values - system.py: Explicit bool() cast for processor health check return - shutdown_condition_evaluator.py: Cast crisis_keywords to list - state_manager.py: Use getattr for behavior.enabled access - ciris_runtime.py: Add None check before service_registry access 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update resume tests to verify helper method calls instead of internal operations (the implementation was refactored to use helper methods) - Update OAuth not-configured test to reflect new on-device mode behavior (when OAuth is not configured, verification proceeds with Google's API) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The tests/logic/adapters/api/routes/ directory was missing an __init__.py file, causing pytest collection errors in CI (works locally due to __pycache__ but fails on fresh CI checkout). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Added explicit else branch to asyncio.CancelledError handlers in Python 3.10 timeout polyfills. The code was already correct but SonarCloud's static analyzer couldn't follow the control flow. Changes: - dma_executor.py: Added else branch to _async_timeout CancelledError handler - ciris_runtime_helpers.py: Same change for consistency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add 72+ new unit tests covering: - LLM service: JSON extraction, config, pricing calculator, circuit breaker - API adapter: config, service injection, health checks, metrics - Auth service: API key management, OAuth, password hashing, permissions - Setup routes: first-run flow, password setup, adapter configuration - Runtime helpers: circuit breaker resume, handler setup, state building - Component builder: component creation with dependencies - Shutdown evaluator: condition evaluation, timeout handling Tests target modules with >20 uncovered lines to improve overall coverage toward 80% target. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix BillingApiClient oauth_provider format ("oauth:google" not "google")
- Add x-api-key header support for billing API authentication
- Fix balance endpoint to POST /v1/billing/credits/check
- Include email and display_name in billing API requests
- Save Google user info in MainActivity for billing client
- Add build script documentation to README.md (deploy-debug.sh, full-rebuild.sh, pull-device-logs.sh)
- Update web assets with latest GUI build
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add teal CIRIS signet logo as Android adaptive icon - Update ic_launcher_foreground.xml with signet vector paths - Update ic_launcher_background.xml with dark background (#1A1A1A) - Generate PNG icons for all density buckets (mdpi to xxxhdpi) - Add round icon variant for adaptive icon support - Update static GUI assets - Bump versionCode to 20, versionName to 1.7.20 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- auth.py:766: Add explicit Optional[str] type for user_id_check variable - setup.py:679: Add assertion to prove wa_cert is not None 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- billing.py: Check for pre-existing billing_client before requiring API key - auth_service.py: Use dict key (user_id) instead of user.wa_id in list_users - test_auth_service_oauth_wa_fix.py: Fix test to expect deduplicated users (1 not 2) - test_setup_routes.py: Use assert_any_call for list_was (called 3 times) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update Google Play Billing Library from 6.1.0 to 7.1.1 (policy requirement) - Update BillingManager.kt to use PendingPurchasesParams API (required for 7.0+) - Add 16KB page size alignment support for newer Android devices - Enable edge-to-edge display for Android 15+ (SDK 35) in MainActivity and LoginActivity - Bump version to 1.7.21 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add regex validation for payment_id to only allow alphanumeric, underscores, hyphens - Reject invalid payment IDs with HTTP 400 before constructing URL path - Prevents potential path traversal attacks via user-controlled URL segments Security: CWE-22 Path Traversal 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Android Native UI: - Add native Kotlin reasoning stream display in InteractFragment - Show real-time task/thought/stage progress with 3-level expansion - SSE client for reasoning-stream with no timeout - New drawables for status dots, chat bubbles, card backgrounds User Profile Display: - Fix agent seeing OAuth ID instead of user's display name - Prioritize user_preferred_name > display_name > nick > name - Agent now addresses users by their preferred name Cleanup: - Update .gitignore to exclude Android built static assets - Remove tracked static assets (now ignored) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The standalone repo contains the static export build which is optimized for standalone/localhost deployments without OAuth dynamic routes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add user prompt transparency for debugging DMA evaluations: Schema Updates: - DMAResultsEvent: Add csdma_prompt, dsdma_prompt, pdma_prompt fields - ASPDMAResultEvent: Add aspdma_prompt field - InitialDMAResults: Add prompt fields to carry from orchestrator - ActionSelectionDMAResult: Add user_prompt field - ConscienceExecutionStepData: Add aspdma_prompt field DMA Evaluators: - CSDMA, PDMA, DSDMA: Store last_user_prompt after building messages - ASPDMA: Store last_user_prompt and include in result Event Flow: - DMA orchestrator captures prompts from evaluators - Step decorators pass prompts to SSE events - DMA_RESULTS event now includes 3 prompts - ASPDMA_RESULT event now includes 1 prompt Android: - InteractFragment: Add recursive JSON parsing for nested objects - Fix expandable context/snapshot display in reasoning stream 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix audit log export path to use platform-aware get_data_dir()
- Fix tsdb_consolidation is_healthy() to avoid false unhealthy reports
- Fix misleading health check warning message in system routes
- Fix DMA prompt YAML placeholders ({{}} -> {}) for proper expansion
- Fix deploy-debug.sh script removing invalid 'local' outside functions
- Add croniter + python-dateutil for cron scheduling support
- Add pypdf + docx2txt for document parsing on Android
- Bump to v1.7.23
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add android:extractNativeLibs="true" to manifest - Set useLegacyPackaging=true for jniLibs in gradle - Bump to v1.7.24 This fixes Google Play error: "Your app does not support 16 KB memory page sizes" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Cast message content to str to satisfy mypy strict typing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Upgrade Chaquopy from 16.0.0 to 17.0.0 for Android 15+ compatibility - Update buildPython to use /usr/bin/python3.10 explicitly - Update PyYAML from 6.0.1 to 6.0.3 for Chaquopy 17 compatibility - Remove unnecessary extractNativeLibs attribute - Rebuild pydantic_core wheels with proper __pycache__ directories - Bump version to 1.7.25 All native libraries now have 16KB ELF segment alignment (0x4000) required for Google Play Store submission. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
MainActivity was storing the exchanged API key in a class variable, but BillingApiClient looked for it in SharedPreferences. This caused BillingApiClient to attempt a second token exchange with Google, which failed because the ID token was already consumed. Now MainActivity also stores the API key in BillingApiClient's SharedPreferences after successful exchange, preventing duplicate auth attempts and fixing the 401 errors on billing/credits calls. Bump version to 1.7.26 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
CIRISGUI-Standalone is a monorepo with workspaces. The package-lock.json lives at the root, not in apps/agui. Fixed the workflow to: - Run npm ci from cirisgui/ (monorepo root) - Use cirisgui/package-lock.json for npm cache This fixes the CI error: "lock file's next@15.3.5 does not satisfy next@15.3.6" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The CIRISGUI-Standalone repo has minor version drift in its lock file (next@15.3.5 vs 15.3.6). Using npm install with --legacy-peer-deps handles this gracefully instead of failing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The IncidentCaptureHandler had a _save_incident_to_graph() method that was never called - incidents were only written to file, not to the graph. Changes: - Add rate limiting (50/minute default) using SecurityFilter pattern - Add deduplication (30s window) to prevent duplicate graph entries - CRITICAL level bypasses rate limiting for urgent incidents - Use MemoryBus.memorize_log() which creates LOG_ENTRY correlations - Fire-and-forget async pattern for non-blocking graph writes - Add set_memory_bus() method for direct memory bus injection - Remove unused _save_incident_to_graph and IncidentNode approach This aligns with the CORRELATIONS_TSDB FSD design for log entries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
|
1 similar comment
|
|
| @@ -0,0 +1 @@ | |||
| (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5653],{589:(e,t,s)=>{"use strict";s.d(t,{$:()=>o,s:()=>n});var i=s(494),a=s(6759),r=s(1279),n=class extends a.k{#e;#t;#s;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||o(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||("pending"===this.state.status?this.scheduleGc():this.#t.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:"continue"})};this.#s=(0,r.II)({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#i({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let s="pending"===this.state.status,i=!this.#s.canStart();try{if(s)t();else{this.#i({type:"pending",variables:e,isPaused:i}),await this.#t.config.onMutate?.(e,this);let t=await this.options.onMutate?.(e);t!==this.state.context&&this.#i({type:"pending",context:t,variables:e,isPaused:i})}let a=await this.#s.start();return await this.#t.config.onSuccess?.(a,e,this.state.context,this),await this.options.onSuccess?.(a,e,this.state.context),await this.#t.config.onSettled?.(a,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(a,null,e,this.state.context),this.#i({type:"success",data:a}),a}catch(t){try{throw await this.#t.config.onError?.(t,e,this.state.context,this),await this.options.onError?.(t,e,this.state.context),await this.#t.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,t,e,this.state.context),t}finally{this.#i({type:"error",error:t})}}finally{this.#t.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),i.jG.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function o(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}},2518:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>m});var i=s(4568),a=s(7620),r=s(7606),n=s(3297),o=s(6258),l=s(704),c=s(6264),d=s(3237),u=s(4893);let h={adapters:{icon:u.RR,label:"Adapters",description:"Communication adapter configurations",color:"purple"},services:{icon:u.DP,label:"Services",description:"Service-specific settings",color:"blue"},security:{icon:u.lm,label:"Security",description:"Security and authentication settings",color:"red"},database:{icon:u.bN,label:"Database",description:"Database connection settings",color:"green"},limits:{icon:u.Pi,label:"Limits",description:"Rate limits and constraints",color:"yellow"},workflow:{icon:u.DP,label:"Workflow",description:"Task and workflow settings",color:"indigo"},telemetry:{icon:u.vK,label:"Telemetry",description:"Monitoring and telemetry",color:"orange"}};function m(){let[e,t]=(0,a.useState)({}),[s,m]=(0,a.useState)(new Set),[p,x]=(0,a.useState)(""),[v,g]=(0,a.useState)(!1),[f,y]=(0,a.useState)(null),b=(0,r.jE)(),{data:j,isLoading:w}=(0,n.I)({queryKey:["config-list"],queryFn:()=>l.AQ.config.getAll()}),{data:N}=(0,n.I)({queryKey:["adapters"],queryFn:()=>l.AQ.system.getAdapters()}),C=(0,o.n)({mutationFn:async e=>{let{key:t,value:s}=e;return l.AQ.config.set(t,s,"Updated via UI")},onSuccess:(s,i)=>{let{key:a}=i;d.Ay.success('Configuration "'.concat(a,'" updated successfully')),b.invalidateQueries({queryKey:["config-list"]}),delete e[a],t({...e})},onError:(e,t)=>{var s,i;let{key:a}=t;d.Ay.error((null==(i=e.response)||null==(s=i.data)?void 0:s.detail)||'Failed to update "'.concat(a,'"'))}}),k=(0,o.n)({mutationFn:async e=>l.AQ.config.delete(e),onSuccess:(e,t)=>{d.Ay.success('Configuration "'.concat(t,'" deleted')),b.invalidateQueries({queryKey:["config-list"]})},onError:(e,t)=>{var s,i;d.Ay.error((null==(i=e.response)||null==(s=i.data)?void 0:s.detail)||'Failed to delete "'.concat(t,'"'))}}),M=(0,a.useMemo)(()=>{if(!j)return{};let e={};j.configs.map(e=>({...e,value:e.value?(0,l.fz)(e.value):null})).filter(e=>{if(!p)return!0;let t=p.toLowerCase();return e.key.toLowerCase().includes(t)||JSON.stringify(e.value).toLowerCase().includes(t)}).forEach(t=>{let s=t.key.split("."),i=s[0]||"default",a=null;for(let[e,s]of Object.entries(h))if(t.key.startsWith(e)){a=e;break}if(t.key.startsWith("adapter.")&&s.length>=3){let e=s[1];i="adapter.".concat(e),a="adapters"}e[i]||(e[i]={name:i,items:[],category:null!=a?a:void 0}),e[i].items.push(t)}),N&&N.adapters&&N.adapters.forEach(t=>{let s="adapter.".concat(t.adapter_id);if(p){let e=p.toLowerCase();if(!t.adapter_id.toLowerCase().includes(e)&&!t.adapter_type.toLowerCase().includes(e)&&!JSON.stringify(t.config||{}).toLowerCase().includes(e))return}e[s]||(e[s]={name:s,items:[],category:"adapters"}),e[s].items.push({key:"".concat(t.adapter_id,".config"),value:t.config||{},updated_at:t.created_at||new Date().toISOString(),updated_by:"system",is_sensitive:!1}),e[s].items.push({key:"".concat(t.adapter_id,".status"),value:{type:t.adapter_type,is_running:t.is_running,last_activity:t.last_activity||"Never"},updated_at:new Date().toISOString(),updated_by:"system",is_sensitive:!1})});let t={};return Object.keys(e).sort().forEach(s=>{t[s]=e[s]}),t},[j,p,N]),R=(0,a.useMemo)(()=>{if(!f)return M;let e={};return Object.entries(M).forEach(t=>{let[s,i]=t;i.category===f&&(e[s]=i)}),e},[M,f]),z=e=>{let t=new Set(s);t.has(e)?t.delete(e):t.add(e),m(t)},S=(s,i)=>{t({...e,[s]:i})},O=(t,s)=>e.hasOwnProperty(t)?e[t]:s,L=t=>e.hasOwnProperty(t),A=async()=>{let t=Object.entries(e);if(0===t.length)return void(0,d.Ay)("No changes to save");for(let[e,s]of t)await C.mutateAsync({key:e,value:s})},_=e=>{let t=O(e.key,e.value),s=L(e.key);return"boolean"==typeof e.value?(0,i.jsxs)("label",{className:"flex items-center cursor-pointer",children:[(0,i.jsx)("input",{type:"checkbox",checked:t,onChange:t=>S(e.key,t.target.checked),className:"h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"}),(0,i.jsx)("span",{className:"ml-2 text-sm text-gray-600",children:t?"Enabled":"Disabled"})]}):"number"==typeof e.value?(0,i.jsx)("input",{type:"number",value:t,onChange:t=>S(e.key,parseFloat(t.target.value)||0),className:"block w-full rounded-md shadow-sm sm:text-sm ".concat(s?"border-yellow-300 bg-yellow-50":"border-gray-300"," focus:ring-indigo-500 focus:border-indigo-500")}):"object"==typeof e.value&&null!==e.value?(0,i.jsx)("div",{className:"relative",children:(0,i.jsx)("textarea",{value:JSON.stringify(t,null,2),onChange:t=>{try{let s=JSON.parse(t.target.value);S(e.key,s)}catch(e){}},className:"block w-full rounded-md shadow-sm sm:text-sm font-mono ".concat(s?"border-yellow-300 bg-yellow-50":"border-gray-300"," focus:ring-indigo-500 focus:border-indigo-500"),rows:4})}):(0,i.jsx)("input",{type:e.is_sensitive?"password":"text",value:t||"",onChange:t=>S(e.key,t.target.value),className:"block w-full rounded-md shadow-sm sm:text-sm ".concat(s?"border-yellow-300 bg-yellow-50":"border-gray-300"," focus:ring-indigo-500 focus:border-indigo-500 ").concat(e.is_sensitive?"font-mono":""),placeholder:null===e.value?"Not set":""})};return(0,i.jsx)(c.O,{requiredRole:"ADMIN",children:(0,i.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[(0,i.jsxs)("div",{className:"mb-8",children:[(0,i.jsx)("h1",{className:"text-3xl font-bold text-gray-900",children:"Configuration Management"}),(0,i.jsx)("p",{className:"mt-2 text-lg text-gray-600",children:"Manage system configuration with live updates and validation"})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[(0,i.jsx)("div",{className:"lg:col-span-1",children:(0,i.jsxs)("div",{className:"bg-white shadow rounded-lg p-4",children:[(0,i.jsx)("h3",{className:"text-sm font-medium text-gray-900 mb-4",children:"Categories"}),(0,i.jsxs)("nav",{className:"space-y-1",children:[(0,i.jsx)("button",{onClick:()=>y(null),className:"w-full text-left px-3 py-2 text-sm rounded-md transition-colors ".concat(null===f?"bg-indigo-100 text-indigo-700":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:"All Configurations"}),Object.entries(h).map(e=>{let[t,s]=e,a=s.icon;return(0,i.jsxs)("button",{onClick:()=>y(t),className:"w-full text-left px-3 py-2 text-sm rounded-md transition-colors flex items-center ".concat(f===t?"bg-".concat(s.color,"-100 text-").concat(s.color,"-700"):"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:[(0,i.jsx)(a,{className:"mr-2",size:"sm"}),s.label]},t)})]}),N&&N.adapters.length>0&&(0,i.jsxs)("div",{className:"mt-6",children:[(0,i.jsx)("h3",{className:"text-sm font-medium text-gray-900 mb-2",children:"Active Adapters"}),(0,i.jsx)("div",{className:"space-y-1 text-xs",children:N.adapters.map(e=>(0,i.jsxs)("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[(0,i.jsx)("span",{className:"font-medium",children:e.adapter_id}),(0,i.jsx)("span",{className:"text-gray-500",children:e.adapter_type})]},e.adapter_id))})]})]})}),(0,i.jsx)("div",{className:"lg:col-span-3",children:(0,i.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,i.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,i.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,i.jsx)("div",{className:"flex-1 max-w-sm",children:(0,i.jsx)("input",{type:"text",placeholder:"Search configurations...",value:p,onChange:e=>x(e.target.value),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})}),(0,i.jsxs)("div",{className:"flex items-center space-x-3 ml-4",children:[(0,i.jsx)("button",{onClick:()=>m(new Set(Object.keys(R))),className:"text-sm text-indigo-600 hover:text-indigo-900",children:"Expand All"}),(0,i.jsx)("button",{onClick:()=>m(new Set),className:"text-sm text-indigo-600 hover:text-indigo-900",children:"Collapse All"}),Object.keys(e).length>0&&(0,i.jsx)("button",{onClick:A,disabled:C.isPending,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50",children:C.isPending?"Saving...":"Save ".concat(Object.keys(e).length," Changes")})]})]}),w?(0,i.jsxs)("div",{className:"text-center py-8",children:[(0,i.jsx)(u.Nl,{className:"mx-auto text-indigo-600",size:"lg"}),(0,i.jsx)("p",{className:"mt-2 text-gray-500",children:"Loading configuration..."})]}):0===Object.keys(R).length?(0,i.jsx)("div",{className:"text-center py-8 text-gray-500",children:"No configurations found matching your criteria."}):(0,i.jsx)("div",{className:"space-y-4",children:Object.entries(R).map(a=>{let[r,n]=a,o=s.has(r),l=n.category?h[n.category]:null;return(0,i.jsxs)("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[(0,i.jsx)("button",{onClick:()=>z(r),className:"w-full px-4 py-3 bg-gray-50 hover:bg-gray-100 transition-colors flex items-center justify-between",children:(0,i.jsxs)("div",{className:"flex items-center",children:[(0,i.jsx)(u.vK,{className:"mr-2 transition-transform ".concat(o?"rotate-90":""),size:"sm"}),(0,i.jsx)("span",{className:"font-medium text-gray-900",children:r}),(0,i.jsxs)("span",{className:"ml-2 text-sm text-gray-500",children:["(",n.items.length," items)"]}),l&&(0,i.jsx)("span",{className:"ml-3 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-".concat(l.color,"-100 text-").concat(l.color,"-800"),children:l.label})]})}),o&&(0,i.jsx)("div",{className:"p-4 space-y-4",children:n.items.map(s=>(0,i.jsxs)("div",{className:"flex items-start space-x-4",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsxs)("div",{className:"flex items-center mb-1",children:[(0,i.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:s.key}),s.is_sensitive&&(0,i.jsx)(u.RY,{className:"ml-2 text-orange-500",size:"sm"}),L(s.key)&&(0,i.jsx)("span",{className:"ml-2 text-xs text-yellow-600",children:"• Modified"})]}),_(s),(0,i.jsxs)("div",{className:"mt-1 text-xs text-gray-500",children:["Last updated: ",new Date(s.updated_at).toLocaleString()," by ",s.updated_by]})]}),(0,i.jsxs)("div",{className:"flex items-center space-x-2",children:[L(s.key)&&(0,i.jsx)("button",{onClick:()=>{delete e[s.key],t({...e})},className:"text-sm text-gray-600 hover:text-gray-900",children:"Reset"}),(0,i.jsx)("button",{onClick:()=>{confirm('Are you sure you want to delete "'.concat(s.key,'"?'))&&k.mutate(s.key)},className:"text-sm text-red-600 hover:text-red-900",children:"Delete"})]})]},s.key))})]},r)})})]})})})]})]})})}},2942:(e,t,s)=>{"use strict";var i=s(2418);s.o(i,"usePathname")&&s.d(t,{usePathname:function(){return i.usePathname}}),s.o(i,"useRouter")&&s.d(t,{useRouter:function(){return i.useRouter}}),s.o(i,"useSearchParams")&&s.d(t,{useSearchParams:function(){return i.useSearchParams}})},4565:(e,t,s)=>{Promise.resolve().then(s.bind(s,2518))},4893:(e,t,s)=>{"use strict";s.d(t,{DP:()=>g,HG:()=>u,Nl:()=>l,O4:()=>d,Pi:()=>n,RR:()=>p,RY:()=>m,Rv:()=>f,XR:()=>o,Zu:()=>b,bN:()=>x,c1:()=>w,fC:()=>N,fK:()=>y,lm:()=>v,md:()=>M,mo:()=>r,uc:()=>j,ui:()=>c,vK:()=>h,xZ:()=>C,xm:()=>k});var i=s(4568);s(7620);let a={xs:{width:12,height:12},sm:{width:16,height:16},md:{width:20,height:20},lg:{width:24,height:24}},r=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})},n=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})},o=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{d:"M11 17a1 1 0 001.447.894l4-2A1 1 0 0017 15V9.236a1 1 0 00-1.447-.894l-4 2a1 1 0 00-.553.894V17zM15.211 6.276a1 1 0 000-1.788l-4.764-2.382a1 1 0 00-.894 0L4.789 4.488a1 1 0 000 1.788l4.764 2.382a1 1 0 00.894 0l4.764-2.382zM4.447 8.342A1 1 0 003 9.236V15a1 1 0 00.553.894l4 2A1 1 0 009 17v-5.764a1 1 0 00-.553-.894l-4-2z"})})},l=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsxs)("svg",{className:"animate-spin ".concat(t),width:r,height:n,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,i.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,i.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})},c=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})},d=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})},u=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"})})},h=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})},m=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M18 8a6 6 0 01-7.743 5.743L10 14l-1 1-1 1H6v2H2v-4l4.257-4.257A6 6 0 1118 8zm-6-4a1 1 0 100 2 2 2 0 012 2 1 1 0 102 0 4 4 0 00-4-4z",clipRule:"evenodd"})})},p=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})})},x=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsxs)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:[(0,i.jsx)("path",{d:"M3 12v3c0 1.657 3.134 3 7 3s7-1.343 7-3v-3c0 1.657-3.134 3-7 3s-7-1.343-7-3z"}),(0,i.jsx)("path",{d:"M3 7v3c0 1.657 3.134 3 7 3s7-1.343 7-3V7c0 1.657-3.134 3-7 3S3 8.657 3 7z"}),(0,i.jsx)("path",{d:"M17 5c0 1.657-3.134 3-7 3S3 6.657 3 5s3.134-3 7-3 7 1.343 7 3z"})]})},v=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})},g=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})},f=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{d:"M8 9a3 3 0 100-6 3 3 0 000 6zM8 11a6 6 0 016 6H2a6 6 0 016-6zM16 7a1 1 0 10-2 0v1h-1a1 1 0 100 2h1v1a1 1 0 102 0v-1h1a1 1 0 100-2h-1V7z"})})},y=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})},b=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})},j=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})})},w=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})},N=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})},C=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})},k=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})},M=e=>{let{status:t,className:s=""}=e;return(0,i.jsx)("span",{className:"w-3 h-3 rounded-full ".concat({green:"bg-green-500",yellow:"bg-yellow-500",red:"bg-red-500",gray:"bg-gray-500"}[t]," ").concat(s)})}},6258:(e,t,s)=>{"use strict";s.d(t,{n:()=>d});var i=s(7620),a=s(589),r=s(494),n=s(2327),o=s(7703),l=class extends n.Q{#a;#r=void 0;#n;#o;constructor(e,t){super(),this.#a=e,this.setOptions(t),this.bindMethods(),this.#l()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#a.defaultMutationOptions(e),(0,o.f8)(this.options,t)||this.#a.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,o.EN)(t.mutationKey)!==(0,o.EN)(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#l(),this.#c(e)}getCurrentResult(){return this.#r}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#l(),this.#c()}mutate(e,t){return this.#o=t,this.#n?.removeObserver(this),this.#n=this.#a.getMutationCache().build(this.#a,this.options),this.#n.addObserver(this),this.#n.execute(e)}#l(){let e=this.#n?.state??(0,a.$)();this.#r={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#c(e){r.jG.batch(()=>{if(this.#o&&this.hasListeners()){let t=this.#r.variables,s=this.#r.context;e?.type==="success"?(this.#o.onSuccess?.(e.data,t,s),this.#o.onSettled?.(e.data,null,t,s)):e?.type==="error"&&(this.#o.onError?.(e.error,t,s),this.#o.onSettled?.(void 0,e.error,t,s))}this.listeners.forEach(e=>{e(this.#r)})})}},c=s(7606);function d(e,t){let s=(0,c.jE)(t),[a]=i.useState(()=>new l(s,e));i.useEffect(()=>{a.setOptions(e)},[a,e]);let n=i.useSyncExternalStore(i.useCallback(e=>a.subscribe(r.jG.batchCalls(e)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),d=i.useCallback((e,t)=>{a.mutate(e,t).catch(o.lQ)},[a]);if(n.error&&(0,o.GU)(a.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:d,mutateAsync:n.mutate}}},6264:(e,t,s)=>{"use strict";s.d(t,{O:()=>o});var i=s(4568),a=s(7620),r=s(2942),n=s(9484);function o(e){let{children:t,requiredRole:s,requiredPermission:o}=e,{user:l,loading:c,hasRole:d,hasPermission:u}=(0,n.A)(),h=(0,r.useRouter)();return((0,a.useEffect)(()=>{if(!c){if(!l)return void h.push("/login");if(s&&!d(s)||o&&!u(o))return void h.push("/unauthorized")}},[l,c,s,o,d,u,h]),c)?(0,i.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,i.jsx)("div",{className:"text-lg",children:"Loading..."})}):l&&(!s||d(s))&&(!o||u(o))?(0,i.jsx)(i.Fragment,{children:t}):null}}},e=>{var t=t=>e(e.s=t);e.O(0,[4534,8903,3297,704,9484,587,8315,7358],()=>t(4565)),_N_E=e.O()}]); | |||
| @@ -0,0 +1 @@ | |||
| (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5653],{589:(e,t,s)=>{"use strict";s.d(t,{$:()=>o,s:()=>n});var i=s(494),a=s(6759),r=s(1279),n=class extends a.k{#e;#t;#s;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||o(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||("pending"===this.state.status?this.scheduleGc():this.#t.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:"continue"})};this.#s=(0,r.II)({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#i({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let s="pending"===this.state.status,i=!this.#s.canStart();try{if(s)t();else{this.#i({type:"pending",variables:e,isPaused:i}),await this.#t.config.onMutate?.(e,this);let t=await this.options.onMutate?.(e);t!==this.state.context&&this.#i({type:"pending",context:t,variables:e,isPaused:i})}let a=await this.#s.start();return await this.#t.config.onSuccess?.(a,e,this.state.context,this),await this.options.onSuccess?.(a,e,this.state.context),await this.#t.config.onSettled?.(a,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(a,null,e,this.state.context),this.#i({type:"success",data:a}),a}catch(t){try{throw await this.#t.config.onError?.(t,e,this.state.context,this),await this.options.onError?.(t,e,this.state.context),await this.#t.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,t,e,this.state.context),t}finally{this.#i({type:"error",error:t})}}finally{this.#t.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),i.jG.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function o(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}},1629:(e,t,s)=>{Promise.resolve().then(s.bind(s,2518))},2518:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>m});var i=s(4568),a=s(7620),r=s(7606),n=s(3297),o=s(6258),l=s(704),c=s(6264),d=s(3237),u=s(4893);let h={adapters:{icon:u.RR,label:"Adapters",description:"Communication adapter configurations",color:"purple"},services:{icon:u.DP,label:"Services",description:"Service-specific settings",color:"blue"},security:{icon:u.lm,label:"Security",description:"Security and authentication settings",color:"red"},database:{icon:u.bN,label:"Database",description:"Database connection settings",color:"green"},limits:{icon:u.Pi,label:"Limits",description:"Rate limits and constraints",color:"yellow"},workflow:{icon:u.DP,label:"Workflow",description:"Task and workflow settings",color:"indigo"},telemetry:{icon:u.vK,label:"Telemetry",description:"Monitoring and telemetry",color:"orange"}};function m(){let[e,t]=(0,a.useState)({}),[s,m]=(0,a.useState)(new Set),[p,x]=(0,a.useState)(""),[v,g]=(0,a.useState)(!1),[f,y]=(0,a.useState)(null),b=(0,r.jE)(),{data:j,isLoading:w}=(0,n.I)({queryKey:["config-list"],queryFn:()=>l.AQ.config.getAll()}),{data:N}=(0,n.I)({queryKey:["adapters"],queryFn:()=>l.AQ.system.getAdapters()}),C=(0,o.n)({mutationFn:async e=>{let{key:t,value:s}=e;return l.AQ.config.set(t,s,"Updated via UI")},onSuccess:(s,i)=>{let{key:a}=i;d.Ay.success('Configuration "'.concat(a,'" updated successfully')),b.invalidateQueries({queryKey:["config-list"]}),delete e[a],t({...e})},onError:(e,t)=>{var s,i;let{key:a}=t;d.Ay.error((null==(i=e.response)||null==(s=i.data)?void 0:s.detail)||'Failed to update "'.concat(a,'"'))}}),k=(0,o.n)({mutationFn:async e=>l.AQ.config.delete(e),onSuccess:(e,t)=>{d.Ay.success('Configuration "'.concat(t,'" deleted')),b.invalidateQueries({queryKey:["config-list"]})},onError:(e,t)=>{var s,i;d.Ay.error((null==(i=e.response)||null==(s=i.data)?void 0:s.detail)||'Failed to delete "'.concat(t,'"'))}}),M=(0,a.useMemo)(()=>{if(!j)return{};let e={};j.configs.map(e=>({...e,value:e.value?(0,l.fz)(e.value):null})).filter(e=>{if(!p)return!0;let t=p.toLowerCase();return e.key.toLowerCase().includes(t)||JSON.stringify(e.value).toLowerCase().includes(t)}).forEach(t=>{let s=t.key.split("."),i=s[0]||"default",a=null;for(let[e,s]of Object.entries(h))if(t.key.startsWith(e)){a=e;break}if(t.key.startsWith("adapter.")&&s.length>=3){let e=s[1];i="adapter.".concat(e),a="adapters"}e[i]||(e[i]={name:i,items:[],category:null!=a?a:void 0}),e[i].items.push(t)}),N&&N.adapters&&N.adapters.forEach(t=>{let s="adapter.".concat(t.adapter_id);if(p){let e=p.toLowerCase();if(!t.adapter_id.toLowerCase().includes(e)&&!t.adapter_type.toLowerCase().includes(e)&&!JSON.stringify(t.config||{}).toLowerCase().includes(e))return}e[s]||(e[s]={name:s,items:[],category:"adapters"}),e[s].items.push({key:"".concat(t.adapter_id,".config"),value:t.config||{},updated_at:t.created_at||new Date().toISOString(),updated_by:"system",is_sensitive:!1}),e[s].items.push({key:"".concat(t.adapter_id,".status"),value:{type:t.adapter_type,is_running:t.is_running,last_activity:t.last_activity||"Never"},updated_at:new Date().toISOString(),updated_by:"system",is_sensitive:!1})});let t={};return Object.keys(e).sort().forEach(s=>{t[s]=e[s]}),t},[j,p,N]),R=(0,a.useMemo)(()=>{if(!f)return M;let e={};return Object.entries(M).forEach(t=>{let[s,i]=t;i.category===f&&(e[s]=i)}),e},[M,f]),z=e=>{let t=new Set(s);t.has(e)?t.delete(e):t.add(e),m(t)},S=(s,i)=>{t({...e,[s]:i})},O=(t,s)=>e.hasOwnProperty(t)?e[t]:s,L=t=>e.hasOwnProperty(t),A=async()=>{let t=Object.entries(e);if(0===t.length)return void(0,d.Ay)("No changes to save");for(let[e,s]of t)await C.mutateAsync({key:e,value:s})},_=e=>{let t=O(e.key,e.value),s=L(e.key);return"boolean"==typeof e.value?(0,i.jsxs)("label",{className:"flex items-center cursor-pointer",children:[(0,i.jsx)("input",{type:"checkbox",checked:t,onChange:t=>S(e.key,t.target.checked),className:"h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"}),(0,i.jsx)("span",{className:"ml-2 text-sm text-gray-600",children:t?"Enabled":"Disabled"})]}):"number"==typeof e.value?(0,i.jsx)("input",{type:"number",value:t,onChange:t=>S(e.key,parseFloat(t.target.value)||0),className:"block w-full rounded-md shadow-sm sm:text-sm ".concat(s?"border-yellow-300 bg-yellow-50":"border-gray-300"," focus:ring-indigo-500 focus:border-indigo-500")}):"object"==typeof e.value&&null!==e.value?(0,i.jsx)("div",{className:"relative",children:(0,i.jsx)("textarea",{value:JSON.stringify(t,null,2),onChange:t=>{try{let s=JSON.parse(t.target.value);S(e.key,s)}catch(e){}},className:"block w-full rounded-md shadow-sm sm:text-sm font-mono ".concat(s?"border-yellow-300 bg-yellow-50":"border-gray-300"," focus:ring-indigo-500 focus:border-indigo-500"),rows:4})}):(0,i.jsx)("input",{type:e.is_sensitive?"password":"text",value:t||"",onChange:t=>S(e.key,t.target.value),className:"block w-full rounded-md shadow-sm sm:text-sm ".concat(s?"border-yellow-300 bg-yellow-50":"border-gray-300"," focus:ring-indigo-500 focus:border-indigo-500 ").concat(e.is_sensitive?"font-mono":""),placeholder:null===e.value?"Not set":""})};return(0,i.jsx)(c.O,{requiredRole:"ADMIN",children:(0,i.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[(0,i.jsxs)("div",{className:"mb-8",children:[(0,i.jsx)("h1",{className:"text-3xl font-bold text-gray-900",children:"Configuration Management"}),(0,i.jsx)("p",{className:"mt-2 text-lg text-gray-600",children:"Manage system configuration with live updates and validation"})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[(0,i.jsx)("div",{className:"lg:col-span-1",children:(0,i.jsxs)("div",{className:"bg-white shadow rounded-lg p-4",children:[(0,i.jsx)("h3",{className:"text-sm font-medium text-gray-900 mb-4",children:"Categories"}),(0,i.jsxs)("nav",{className:"space-y-1",children:[(0,i.jsx)("button",{onClick:()=>y(null),className:"w-full text-left px-3 py-2 text-sm rounded-md transition-colors ".concat(null===f?"bg-indigo-100 text-indigo-700":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:"All Configurations"}),Object.entries(h).map(e=>{let[t,s]=e,a=s.icon;return(0,i.jsxs)("button",{onClick:()=>y(t),className:"w-full text-left px-3 py-2 text-sm rounded-md transition-colors flex items-center ".concat(f===t?"bg-".concat(s.color,"-100 text-").concat(s.color,"-700"):"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:[(0,i.jsx)(a,{className:"mr-2",size:"sm"}),s.label]},t)})]}),N&&N.adapters.length>0&&(0,i.jsxs)("div",{className:"mt-6",children:[(0,i.jsx)("h3",{className:"text-sm font-medium text-gray-900 mb-2",children:"Active Adapters"}),(0,i.jsx)("div",{className:"space-y-1 text-xs",children:N.adapters.map(e=>(0,i.jsxs)("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[(0,i.jsx)("span",{className:"font-medium",children:e.adapter_id}),(0,i.jsx)("span",{className:"text-gray-500",children:e.adapter_type})]},e.adapter_id))})]})]})}),(0,i.jsx)("div",{className:"lg:col-span-3",children:(0,i.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,i.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,i.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,i.jsx)("div",{className:"flex-1 max-w-sm",children:(0,i.jsx)("input",{type:"text",placeholder:"Search configurations...",value:p,onChange:e=>x(e.target.value),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})}),(0,i.jsxs)("div",{className:"flex items-center space-x-3 ml-4",children:[(0,i.jsx)("button",{onClick:()=>m(new Set(Object.keys(R))),className:"text-sm text-indigo-600 hover:text-indigo-900",children:"Expand All"}),(0,i.jsx)("button",{onClick:()=>m(new Set),className:"text-sm text-indigo-600 hover:text-indigo-900",children:"Collapse All"}),Object.keys(e).length>0&&(0,i.jsx)("button",{onClick:A,disabled:C.isPending,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50",children:C.isPending?"Saving...":"Save ".concat(Object.keys(e).length," Changes")})]})]}),w?(0,i.jsxs)("div",{className:"text-center py-8",children:[(0,i.jsx)(u.Nl,{className:"mx-auto text-indigo-600",size:"lg"}),(0,i.jsx)("p",{className:"mt-2 text-gray-500",children:"Loading configuration..."})]}):0===Object.keys(R).length?(0,i.jsx)("div",{className:"text-center py-8 text-gray-500",children:"No configurations found matching your criteria."}):(0,i.jsx)("div",{className:"space-y-4",children:Object.entries(R).map(a=>{let[r,n]=a,o=s.has(r),l=n.category?h[n.category]:null;return(0,i.jsxs)("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[(0,i.jsx)("button",{onClick:()=>z(r),className:"w-full px-4 py-3 bg-gray-50 hover:bg-gray-100 transition-colors flex items-center justify-between",children:(0,i.jsxs)("div",{className:"flex items-center",children:[(0,i.jsx)(u.vK,{className:"mr-2 transition-transform ".concat(o?"rotate-90":""),size:"sm"}),(0,i.jsx)("span",{className:"font-medium text-gray-900",children:r}),(0,i.jsxs)("span",{className:"ml-2 text-sm text-gray-500",children:["(",n.items.length," items)"]}),l&&(0,i.jsx)("span",{className:"ml-3 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-".concat(l.color,"-100 text-").concat(l.color,"-800"),children:l.label})]})}),o&&(0,i.jsx)("div",{className:"p-4 space-y-4",children:n.items.map(s=>(0,i.jsxs)("div",{className:"flex items-start space-x-4",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsxs)("div",{className:"flex items-center mb-1",children:[(0,i.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:s.key}),s.is_sensitive&&(0,i.jsx)(u.RY,{className:"ml-2 text-orange-500",size:"sm"}),L(s.key)&&(0,i.jsx)("span",{className:"ml-2 text-xs text-yellow-600",children:"• Modified"})]}),_(s),(0,i.jsxs)("div",{className:"mt-1 text-xs text-gray-500",children:["Last updated: ",new Date(s.updated_at).toLocaleString()," by ",s.updated_by]})]}),(0,i.jsxs)("div",{className:"flex items-center space-x-2",children:[L(s.key)&&(0,i.jsx)("button",{onClick:()=>{delete e[s.key],t({...e})},className:"text-sm text-gray-600 hover:text-gray-900",children:"Reset"}),(0,i.jsx)("button",{onClick:()=>{confirm('Are you sure you want to delete "'.concat(s.key,'"?'))&&k.mutate(s.key)},className:"text-sm text-red-600 hover:text-red-900",children:"Delete"})]})]},s.key))})]},r)})})]})})})]})]})})}},2942:(e,t,s)=>{"use strict";var i=s(2418);s.o(i,"usePathname")&&s.d(t,{usePathname:function(){return i.usePathname}}),s.o(i,"useRouter")&&s.d(t,{useRouter:function(){return i.useRouter}}),s.o(i,"useSearchParams")&&s.d(t,{useSearchParams:function(){return i.useSearchParams}})},4893:(e,t,s)=>{"use strict";s.d(t,{DP:()=>g,HG:()=>u,Nl:()=>l,O4:()=>d,Pi:()=>n,RR:()=>p,RY:()=>m,Rv:()=>f,XR:()=>o,Zu:()=>b,bN:()=>x,c1:()=>w,fC:()=>N,fK:()=>y,lm:()=>v,md:()=>M,mo:()=>r,uc:()=>j,ui:()=>c,vK:()=>h,xZ:()=>C,xm:()=>k});var i=s(4568);s(7620);let a={xs:{width:12,height:12},sm:{width:16,height:16},md:{width:20,height:20},lg:{width:24,height:24}},r=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})},n=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})},o=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{d:"M11 17a1 1 0 001.447.894l4-2A1 1 0 0017 15V9.236a1 1 0 00-1.447-.894l-4 2a1 1 0 00-.553.894V17zM15.211 6.276a1 1 0 000-1.788l-4.764-2.382a1 1 0 00-.894 0L4.789 4.488a1 1 0 000 1.788l4.764 2.382a1 1 0 00.894 0l4.764-2.382zM4.447 8.342A1 1 0 003 9.236V15a1 1 0 00.553.894l4 2A1 1 0 009 17v-5.764a1 1 0 00-.553-.894l-4-2z"})})},l=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsxs)("svg",{className:"animate-spin ".concat(t),width:r,height:n,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,i.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,i.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})},c=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})},d=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})},u=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"})})},h=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})},m=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M18 8a6 6 0 01-7.743 5.743L10 14l-1 1-1 1H6v2H2v-4l4.257-4.257A6 6 0 1118 8zm-6-4a1 1 0 100 2 2 2 0 012 2 1 1 0 102 0 4 4 0 00-4-4z",clipRule:"evenodd"})})},p=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})})},x=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsxs)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:[(0,i.jsx)("path",{d:"M3 12v3c0 1.657 3.134 3 7 3s7-1.343 7-3v-3c0 1.657-3.134 3-7 3s-7-1.343-7-3z"}),(0,i.jsx)("path",{d:"M3 7v3c0 1.657 3.134 3 7 3s7-1.343 7-3V7c0 1.657-3.134 3-7 3S3 8.657 3 7z"}),(0,i.jsx)("path",{d:"M17 5c0 1.657-3.134 3-7 3S3 6.657 3 5s3.134-3 7-3 7 1.343 7 3z"})]})},v=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})},g=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})},f=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{d:"M8 9a3 3 0 100-6 3 3 0 000 6zM8 11a6 6 0 016 6H2a6 6 0 016-6zM16 7a1 1 0 10-2 0v1h-1a1 1 0 100 2h1v1a1 1 0 102 0v-1h1a1 1 0 100-2h-1V7z"})})},y=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})},b=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})},j=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})})},w=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})},N=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})},C=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})},k=e=>{let{className:t="",size:s="md"}=e,{width:r,height:n}=a[s];return(0,i.jsx)("svg",{className:t,width:r,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})},M=e=>{let{status:t,className:s=""}=e;return(0,i.jsx)("span",{className:"w-3 h-3 rounded-full ".concat({green:"bg-green-500",yellow:"bg-yellow-500",red:"bg-red-500",gray:"bg-gray-500"}[t]," ").concat(s)})}},6258:(e,t,s)=>{"use strict";s.d(t,{n:()=>d});var i=s(7620),a=s(589),r=s(494),n=s(2327),o=s(7703),l=class extends n.Q{#a;#r=void 0;#n;#o;constructor(e,t){super(),this.#a=e,this.setOptions(t),this.bindMethods(),this.#l()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#a.defaultMutationOptions(e),(0,o.f8)(this.options,t)||this.#a.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,o.EN)(t.mutationKey)!==(0,o.EN)(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#l(),this.#c(e)}getCurrentResult(){return this.#r}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#l(),this.#c()}mutate(e,t){return this.#o=t,this.#n?.removeObserver(this),this.#n=this.#a.getMutationCache().build(this.#a,this.options),this.#n.addObserver(this),this.#n.execute(e)}#l(){let e=this.#n?.state??(0,a.$)();this.#r={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#c(e){r.jG.batch(()=>{if(this.#o&&this.hasListeners()){let t=this.#r.variables,s=this.#r.context;e?.type==="success"?(this.#o.onSuccess?.(e.data,t,s),this.#o.onSettled?.(e.data,null,t,s)):e?.type==="error"&&(this.#o.onError?.(e.error,t,s),this.#o.onSettled?.(void 0,e.error,t,s))}this.listeners.forEach(e=>{e(this.#r)})})}},c=s(7606);function d(e,t){let s=(0,c.jE)(t),[a]=i.useState(()=>new l(s,e));i.useEffect(()=>{a.setOptions(e)},[a,e]);let n=i.useSyncExternalStore(i.useCallback(e=>a.subscribe(r.jG.batchCalls(e)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),d=i.useCallback((e,t)=>{a.mutate(e,t).catch(o.lQ)},[a]);if(n.error&&(0,o.GU)(a.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:d,mutateAsync:n.mutate}}},6264:(e,t,s)=>{"use strict";s.d(t,{O:()=>o});var i=s(4568),a=s(7620),r=s(2942),n=s(9484);function o(e){let{children:t,requiredRole:s,requiredPermission:o}=e,{user:l,loading:c,hasRole:d,hasPermission:u}=(0,n.A)(),h=(0,r.useRouter)();return((0,a.useEffect)(()=>{if(!c){if(!l)return void h.push("/login");if(s&&!d(s)||o&&!u(o))return void h.push("/unauthorized")}},[l,c,s,o,d,u,h]),c)?(0,i.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,i.jsx)("div",{className:"text-lg",children:"Loading..."})}):l&&(!s||d(s))&&(!o||u(o))?(0,i.jsx)(i.Fragment,{children:t}):null}}},e=>{var t=t=>e(e.s=t);e.O(0,[4534,8903,3297,704,9484,587,8315,7358],()=>t(1629)),_N_E=e.O()}]); | |||
| @@ -0,0 +1 @@ | |||
| (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1186],{589:(e,t,s)=>{"use strict";s.d(t,{$:()=>l,s:()=>n});var r=s(494),a=s(6759),i=s(1279),n=class extends a.k{#e;#t;#s;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||l(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||("pending"===this.state.status?this.scheduleGc():this.#t.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#r({type:"continue"})};this.#s=(0,i.II)({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#r({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let s="pending"===this.state.status,r=!this.#s.canStart();try{if(s)t();else{this.#r({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let t=await this.options.onMutate?.(e);t!==this.state.context&&this.#r({type:"pending",context:t,variables:e,isPaused:r})}let a=await this.#s.start();return await this.#t.config.onSuccess?.(a,e,this.state.context,this),await this.options.onSuccess?.(a,e,this.state.context),await this.#t.config.onSettled?.(a,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(a,null,e,this.state.context),this.#r({type:"success",data:a}),a}catch(t){try{throw await this.#t.config.onError?.(t,e,this.state.context,this),await this.options.onError?.(t,e,this.state.context),await this.#t.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,t,e,this.state.context),t}finally{this.#r({type:"error",error:t})}}finally{this.#t.runNext(this)}}#r(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),r.jG.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function l(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}},739:(e,t,s)=>{Promise.resolve().then(s.bind(s,6107))},2942:(e,t,s)=>{"use strict";var r=s(2418);s.o(r,"usePathname")&&s.d(t,{usePathname:function(){return r.usePathname}}),s.o(r,"useRouter")&&s.d(t,{useRouter:function(){return r.useRouter}}),s.o(r,"useSearchParams")&&s.d(t,{useSearchParams:function(){return r.useSearchParams}})},4893:(e,t,s)=>{"use strict";s.d(t,{DP:()=>y,HG:()=>u,Nl:()=>o,O4:()=>c,Pi:()=>n,RR:()=>x,RY:()=>m,Rv:()=>v,XR:()=>l,Zu:()=>f,bN:()=>p,c1:()=>N,fC:()=>w,fK:()=>j,lm:()=>g,md:()=>A,mo:()=>i,uc:()=>b,ui:()=>d,vK:()=>h,xZ:()=>_,xm:()=>C});var r=s(4568);s(7620);let a={xs:{width:12,height:12},sm:{width:16,height:16},md:{width:20,height:20},lg:{width:24,height:24}},i=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})},n=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})},l=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{d:"M11 17a1 1 0 001.447.894l4-2A1 1 0 0017 15V9.236a1 1 0 00-1.447-.894l-4 2a1 1 0 00-.553.894V17zM15.211 6.276a1 1 0 000-1.788l-4.764-2.382a1 1 0 00-.894 0L4.789 4.488a1 1 0 000 1.788l4.764 2.382a1 1 0 00.894 0l4.764-2.382zM4.447 8.342A1 1 0 003 9.236V15a1 1 0 00.553.894l4 2A1 1 0 009 17v-5.764a1 1 0 00-.553-.894l-4-2z"})})},o=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsxs)("svg",{className:"animate-spin ".concat(t),width:i,height:n,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})},d=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})},c=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})},u=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"})})},h=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})},m=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 8a6 6 0 01-7.743 5.743L10 14l-1 1-1 1H6v2H2v-4l4.257-4.257A6 6 0 1118 8zm-6-4a1 1 0 100 2 2 2 0 012 2 1 1 0 102 0 4 4 0 00-4-4z",clipRule:"evenodd"})})},x=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})})},p=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsxs)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:[(0,r.jsx)("path",{d:"M3 12v3c0 1.657 3.134 3 7 3s7-1.343 7-3v-3c0 1.657-3.134 3-7 3s-7-1.343-7-3z"}),(0,r.jsx)("path",{d:"M3 7v3c0 1.657 3.134 3 7 3s7-1.343 7-3V7c0 1.657-3.134 3-7 3S3 8.657 3 7z"}),(0,r.jsx)("path",{d:"M17 5c0 1.657-3.134 3-7 3S3 6.657 3 5s3.134-3 7-3 7 1.343 7 3z"})]})},g=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})},y=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})},v=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 9a3 3 0 100-6 3 3 0 000 6zM8 11a6 6 0 016 6H2a6 6 0 016-6zM16 7a1 1 0 10-2 0v1h-1a1 1 0 100 2h1v1a1 1 0 102 0v-1h1a1 1 0 100-2h-1V7z"})})},j=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})},f=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})},b=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})})},N=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})},w=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})},_=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})},C=e=>{let{className:t="",size:s="md"}=e,{width:i,height:n}=a[s];return(0,r.jsx)("svg",{className:t,width:i,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})},A=e=>{let{status:t,className:s=""}=e;return(0,r.jsx)("span",{className:"w-3 h-3 rounded-full ".concat({green:"bg-green-500",yellow:"bg-yellow-500",red:"bg-red-500",gray:"bg-gray-500"}[t]," ").concat(s)})}},6107:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>m});var r=s(4568),a=s(7620),i=s(7606),n=s(3297),l=s(6258),o=s(704),d=s(9484),c=s(3237),u=s(4893);function h(e){var t;let{adapterType:s,adapterId:i,isEdit:n=!1,config:l,setConfig:o,onSubmit:d,onClose:u,isPending:h=!1}=e,[m,x]=a.useState(!1),[p,g]=a.useState(null),y={width:"100%",padding:"8px 12px",border:"1px solid #ccc",borderRadius:"4px",fontSize:"14px",marginTop:"5px"},v={display:"block",marginBottom:"5px",fontSize:"14px",fontWeight:"500"},j={marginBottom:"15px"};return(0,r.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",zIndex:9999},children:(0,r.jsxs)("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",backgroundColor:"white",padding:"30px",borderRadius:"8px",maxWidth:"500px",width:"90%",maxHeight:"80vh",overflowY:"auto"},children:[(0,r.jsxs)("h3",{style:{fontSize:"18px",fontWeight:"bold",marginBottom:"15px"},children:[n?"Edit":"Configure"," ",s.charAt(0).toUpperCase()+s.slice(1)," Adapter ",i?"(".concat(i,")"):""]}),"discord"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:j,children:[(0,r.jsxs)("label",{style:v,children:["Bot Token ",(0,r.jsx)("span",{style:{color:"red"},children:"*"})]}),(0,r.jsx)("input",{type:"password",value:l.bot_token||"",onChange:e=>o({...l,bot_token:e.target.value}),style:y,placeholder:n?"••••••••":"Your Discord bot token"})]}),(0,r.jsxs)("div",{style:j,children:[(0,r.jsxs)("label",{style:v,children:["Server ID ",(0,r.jsx)("span",{style:{color:"red"},children:"*"})]}),(0,r.jsx)("input",{type:"text",value:l.server_id||"",onChange:e=>o({...l,server_id:e.target.value}),style:y,placeholder:"Discord server/guild ID"})]}),(0,r.jsxs)("div",{style:j,children:[(0,r.jsx)("label",{style:v,children:"Home Channel ID"}),(0,r.jsx)("input",{type:"text",value:l.home_channel_id||"",onChange:e=>o({...l,home_channel_id:e.target.value}),style:y,placeholder:"Primary channel for agent"})]}),(0,r.jsxs)("div",{style:j,children:[(0,r.jsx)("label",{style:v,children:"Deferral Channel ID"}),(0,r.jsx)("input",{type:"text",value:l.deferral_channel_id||"",onChange:e=>o({...l,deferral_channel_id:e.target.value}),style:y,placeholder:"Channel for deferred messages"})]}),(0,r.jsxs)("div",{style:j,children:[(0,r.jsx)("label",{style:v,children:"Monitored Channel IDs (comma-separated)"}),(0,r.jsx)("input",{type:"text",value:Array.isArray(l.monitored_channel_ids)?l.monitored_channel_ids.join(", "):"",onChange:e=>o({...l,monitored_channel_ids:e.target.value?e.target.value.split(",").map(e=>e.trim()):[]}),style:y,placeholder:"Channel IDs to monitor"})]}),(0,r.jsx)("div",{style:j,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:!1!==l.respond_to_mentions,onChange:e=>o({...l,respond_to_mentions:e.target.checked}),style:{marginRight:"8px"}}),"Respond to Mentions"]})}),(0,r.jsx)("div",{style:j,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:!1!==l.respond_to_dms,onChange:e=>o({...l,respond_to_dms:e.target.checked}),style:{marginRight:"8px"}}),"Respond to DMs"]})})]}),"api"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:j,children:[(0,r.jsxs)("label",{style:v,children:["Host ",(0,r.jsx)("span",{style:{color:"red"},children:"*"})]}),(0,r.jsx)("input",{type:"text",value:l.host||"",onChange:e=>o({...l,host:e.target.value}),style:y,placeholder:"0.0.0.0"})]}),(0,r.jsxs)("div",{style:j,children:[(0,r.jsxs)("label",{style:v,children:["Port ",(0,r.jsx)("span",{style:{color:"red"},children:"*"})]}),(0,r.jsx)("input",{type:"number",value:l.port||"",onChange:e=>o({...l,port:parseInt(e.target.value)||8080}),style:y,placeholder:"8080"})]}),(0,r.jsxs)("div",{style:j,children:[(0,r.jsx)("label",{style:v,children:"CORS Origins"}),(0,r.jsx)("input",{type:"text",value:(null==(t=l.cors_origins)?void 0:t.join(", "))||"*",onChange:e=>o({...l,cors_origins:e.target.value.split(",").map(e=>e.trim())}),style:y,placeholder:"*, http://localhost:3000"})]}),(0,r.jsx)("div",{style:j,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:!1!==l.enable_auth,onChange:e=>o({...l,enable_auth:e.target.checked}),style:{marginRight:"8px"}}),"Enable Authentication"]})}),(0,r.jsx)("div",{style:j,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:!1!==l.cors_enabled,onChange:e=>o({...l,cors_enabled:e.target.checked}),style:{marginRight:"8px"}}),"Enable CORS"]})})]}),"cli"===s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:j,children:[(0,r.jsx)("label",{style:v,children:"Prompt"}),(0,r.jsx)("input",{type:"text",value:l.prompt||"",onChange:e=>o({...l,prompt:e.target.value}),style:y,placeholder:"> "})]}),(0,r.jsxs)("div",{style:j,children:[(0,r.jsx)("label",{style:v,children:"History File"}),(0,r.jsx)("input",{type:"text",value:l.history_file||"",onChange:e=>o({...l,history_file:e.target.value}),style:y,placeholder:".ciris_history"})]}),(0,r.jsx)("div",{style:j,children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:l.enable_colors||!1,onChange:e=>o({...l,enable_colors:e.target.checked}),style:{marginRight:"8px"}}),"Enable Colors"]})})]}),(0,r.jsxs)("div",{style:{marginTop:"20px",borderTop:"1px solid #e5e7eb",paddingTop:"20px"},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>x(!m),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",border:"1px solid #e5e7eb",borderRadius:"4px",backgroundColor:"white",cursor:"pointer",fontSize:"14px",fontWeight:"500",width:"100%",justifyContent:"space-between"},children:[(0,r.jsx)("span",{children:"Advanced Configuration (JSON)"}),(0,r.jsx)("span",{style:{fontSize:"12px"},children:m?"▼":"▶"})]}),m&&(0,r.jsxs)("div",{style:{marginTop:"15px"},children:[(0,r.jsxs)("label",{style:{...v,marginBottom:"10px"},children:["Raw Configuration JSON",p&&(0,r.jsx)("span",{style:{color:"red",fontSize:"12px",marginLeft:"10px"},children:p})]}),(0,r.jsx)("textarea",{value:JSON.stringify(l,null,2),onChange:e=>{try{let t=JSON.parse(e.target.value);o(t),g(null)}catch(e){g("Invalid JSON")}},style:{...y,fontFamily:"monospace",fontSize:"12px",minHeight:"200px",resize:"vertical",borderColor:p?"red":"#ccc"},placeholder:"{}"}),(0,r.jsx)("p",{style:{fontSize:"12px",color:"#666",marginTop:"5px"},children:"Edit the raw JSON configuration. Changes here will override the form fields above."})]})]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px",marginTop:"20px"},children:[(0,r.jsx)("button",{onClick:u,style:{padding:"8px 16px",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:"white",cursor:"pointer"},children:"Cancel"}),(0,r.jsx)("button",{onClick:()=>{if("discord"===s){if(!l.bot_token)return void c.Ay.error("Bot token is required");if(!l.server_id)return void c.Ay.error("Server ID is required")}else if("api"===s){if(!l.host)return void c.Ay.error("Host is required");if(!l.port)return void c.Ay.error("Port is required")}d(s,l)},disabled:h,style:{padding:"8px 16px",backgroundColor:h?"#ccc":"#4f46e5",color:"white",border:"none",borderRadius:"4px",cursor:h?"not-allowed":"pointer"},children:h?n?"Saving...":"Registering...":n?"Save Changes":"Register Adapter"})]})]})})}function m(){var e,t,s,m,x,p,g,y,v,j,f,b,N,w,_,C,A,k,M,R,S,I;let{hasRole:O}=(0,d.A)(),z=(0,i.jE)(),[E,L]=(0,a.useState)(null),[P,F]=(0,a.useState)(null),[T,D]=(0,a.useState)({}),B=e=>{if(e.startsWith("registry.ServiceType.")){let t=e.split(".");if(t.length>=4){let e=t[2],s=t[3].split("_")[0];if("DiscordAdapter"===s){if("WISE_AUTHORITY"===e)return"DISCORD-WISE";if("COMMUNICATION"===e)return"DISCORD-COMM"}else if("APICommunicationService"===s)return"API-COMM";else if("APIToolService"===s)return"API-TOOL";else if("APIRuntimeControlService"===s)return"API-RUNTIME";else if("DiscordToolService"===s)return"DISCORD-TOOL";else if("MockLLMService"===s)return"MOCK-LLM";else if("WiseAuthorityService"===s)return"CORE-WISE";else if("SecretsToolService"===s)return"CORE-TOOL";else if("LocalGraphMemoryService"===s)return"MEMORY";else if("TimeService"===s)return"TIME";else return e.replace(/_/g,"-")}}if(e.startsWith("direct.")){let t=e.split(".");return t[t.length-1].replace(/Service$/,"").replace(/([A-Z])/g,"-$1").toUpperCase().replace(/^-/,"").replace(/-+/g,"-")}return e};(E||P)&&console.log("Modal states:",{confirmDialog:E,adapterConfigModal:P});let{data:q}=(0,n.I)({queryKey:["system-health"],queryFn:()=>o.AQ.system.getHealth(),refetchInterval:5e3}),{data:H}=(0,n.I)({queryKey:["system-services"],queryFn:()=>o.AQ.system.getServices(),refetchInterval:5e3}),{data:K}=(0,n.I)({queryKey:["system-resources"],queryFn:()=>o.AQ.system.getResources(),refetchInterval:5e3}),{data:U}=(0,n.I)({queryKey:["system-processors"],queryFn:()=>o.AQ.system.getProcessorStates(),refetchInterval:5e3,enabled:O("ADMIN")}),{data:Q}=(0,n.I)({queryKey:["system-runtime-state"],queryFn:()=>o.AQ.system.getRuntimeState(),refetchInterval:5e3}),W=Q?{is_paused:"paused"===Q.processor_state,cognitive_state:("UNKNOWN"!==Q.cognitive_state?Q.cognitive_state:null==q||null==(e=q.cognitive_state)?void 0:e.toUpperCase())||"WORK",queue_depth:Q.queue_depth,processor_status:Q.processor_state}:null,{data:V}=(0,n.I)({queryKey:["system-adapters"],queryFn:()=>o.AQ.system.getAdapters(),refetchInterval:5e3,enabled:O("ADMIN")}),{data:G}=(0,n.I)({queryKey:["agent-channels"],queryFn:()=>o.AQ.agent.getChannels(),refetchInterval:5e3}),{data:J}=(0,n.I)({queryKey:["telemetry-overview"],queryFn:()=>o.AQ.telemetry.getOverview(),refetchInterval:3e4}),Y=(0,l.n)({mutationFn:()=>o.AQ.system.pauseRuntime(),onSuccess:()=>{c.Ay.success("Runtime paused"),z.invalidateQueries({queryKey:["system-health"]})},onError:()=>{c.Ay.error("Failed to pause runtime")}}),$=(0,l.n)({mutationFn:()=>o.AQ.system.resumeRuntime(),onSuccess:()=>{c.Ay.success("Runtime resumed"),z.invalidateQueries({queryKey:["system-health"]})},onError:()=>{c.Ay.error("Failed to resume runtime")}}),Z=(0,l.n)({mutationFn:e=>{let{name:t,duration:s}=e;return o.AQ.system.pauseProcessor(t,s)},onSuccess:(e,t)=>{let{name:s}=t;c.Ay.success("Processor ".concat(s," paused")),z.invalidateQueries({queryKey:["system-processors"]})},onError:(e,t)=>{let{name:s}=t;c.Ay.error("Failed to pause processor ".concat(s))}}),X=(0,l.n)({mutationFn:e=>o.AQ.system.resumeProcessor(e),onSuccess:(e,t)=>{c.Ay.success("Processor ".concat(t," resumed")),z.invalidateQueries({queryKey:["system-processors"]})},onError:(e,t)=>{c.Ay.error("Failed to resume processor ".concat(t))}}),ee=(0,l.n)({mutationFn:e=>o.AQ.system.reloadAdapter(e),onSuccess:(e,t)=>{c.Ay.success("Adapter ".concat(t," reloaded")),z.invalidateQueries({queryKey:["system-adapters"]})},onError:(e,t)=>{c.Ay.error("Failed to reload adapter ".concat(t))}}),et=(0,l.n)({mutationFn:e=>o.AQ.system.unregisterAdapter(e),onSuccess:(e,t)=>{c.Ay.success("Adapter ".concat(t," removed")),z.invalidateQueries({queryKey:["system-adapters"]})},onError:(e,t)=>{c.Ay.error("Failed to remove adapter ".concat(t))}}),es=(0,l.n)({mutationFn:e=>{let{adapterType:t,config:s}=e;return o.AQ.system.registerAdapter(t,s)},onSuccess:(e,t)=>{let{adapterType:s}=t;c.Ay.success("".concat(s," adapter registered")),z.invalidateQueries({queryKey:["system-adapters"]}),z.invalidateQueries({queryKey:["agent-channels"]}),F(null),D({})},onError:(e,t)=>{let{adapterType:s}=t;c.Ay.error("Failed to register ".concat(s," adapter"))}}),er=e=>{switch(e){case"healthy":return"green";case"degraded":return"yellow";case"unhealthy":return"red";default:return"gray"}};return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("div",{className:"bg-white shadow",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:px-6",children:[(0,r.jsx)("h2",{className:"text-2xl font-bold text-gray-900",children:"System Status"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:"Comprehensive system health monitoring and runtime control"})]})}),(0,r.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,r.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"System Overview"}),q&&(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-5 sm:p-6 rounded-lg border-2 border-gray-200",children:[(0,r.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:"Overall Health"}),(0,r.jsx)("dd",{className:"mt-2 flex items-center",children:(0,r.jsxs)("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-lg font-semibold bg-".concat(er(q.status),"-100 text-").concat(er(q.status),"-800"),children:[(0,r.jsx)("span",{className:"mr-2",children:(e=>{switch(e){case"healthy":return"✓";case"degraded":return"!";case"unhealthy":return"✗";default:return"?"}})(q.status)}),null==(t=q.status)?void 0:t.toUpperCase()]})})]}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-5 sm:p-6 rounded-lg border-2 border-gray-200",children:[(0,r.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:"Uptime"}),(0,r.jsx)("dd",{className:"mt-2 text-2xl font-semibold text-gray-900",children:q.uptime_seconds?(e=>{let t=Math.floor(e/86400),s=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return"".concat(t,"d ").concat(s,"h ").concat(r,"m")})(q.uptime_seconds):"N/A"})]}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-5 sm:p-6 rounded-lg border-2 border-gray-200",children:[(0,r.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:"Memory Usage"}),(0,r.jsx)("dd",{className:"mt-2 text-2xl font-semibold text-gray-900",children:(null==K||null==(s=K.current_usage)?void 0:s.memory_mb)?"".concat(K.current_usage.memory_mb.toFixed(1)," MB"):"N/A"})]}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-5 sm:p-6 rounded-lg border-2 border-gray-200",children:[(0,r.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:"CPU Usage"}),(0,r.jsx)("dd",{className:"mt-2 text-2xl font-semibold text-gray-900",children:(null==K||null==(m=K.current_usage)?void 0:m.cpu_percent)?"".concat(K.current_usage.cpu_percent.toFixed(1),"%"):"N/A"})]})]})]})}),(0,r.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,r.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Resource Usage"}),K?(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"CPU Usage"}),(0,r.jsxs)("span",{className:"text-lg font-bold ".concat((null==K||null==(x=K.current_usage)?void 0:x.cpu_percent)>80?"text-red-600":(null==K||null==(p=K.current_usage)?void 0:p.cpu_percent)>60?"text-yellow-600":"text-green-600"),children:[(null==K||null==(y=K.current_usage)||null==(g=y.cpu_percent)?void 0:g.toFixed(1))||0,"%"]})]}),(0,r.jsx)("div",{className:"relative",children:(0,r.jsx)("div",{className:"overflow-hidden h-4 text-xs flex rounded-full bg-gray-200",children:(0,r.jsx)("div",{style:{width:"".concat((null==K||null==(v=K.current_usage)?void 0:v.cpu_percent)||0,"%")},className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center transition-all duration-300 ".concat((null==K||null==(j=K.current_usage)?void 0:j.cpu_percent)>80?"bg-red-500":(null==K||null==(f=K.current_usage)?void 0:f.cpu_percent)>60?"bg-yellow-500":"bg-blue-500")})})})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Memory Usage"}),(0,r.jsxs)("span",{className:"text-lg font-bold ".concat((null==K||null==(b=K.current_usage)?void 0:b.memory_percent)>80?"text-red-600":(null==K||null==(N=K.current_usage)?void 0:N.memory_percent)>60?"text-yellow-600":"text-green-600"),children:[(null==K||null==(w=K.current_usage)?void 0:w.memory_mb)?K.current_usage.memory_mb.toFixed(1):0," MB"]})]}),(0,r.jsx)("div",{className:"relative",children:(0,r.jsx)("div",{className:"overflow-hidden h-4 text-xs flex rounded-full bg-gray-200",children:(0,r.jsx)("div",{style:{width:"".concat((null==K||null==(_=K.current_usage)?void 0:_.memory_percent)||0,"%")},className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center transition-all duration-300 ".concat((null==K||null==(C=K.current_usage)?void 0:C.memory_percent)>80?"bg-red-500":(null==K||null==(A=K.current_usage)?void 0:A.memory_percent)>60?"bg-yellow-500":"bg-green-500")})})}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:[(null==K||null==(M=K.current_usage)||null==(k=M.memory_percent)?void 0:k.toFixed(1))||0,"% utilized"]})]}),(0,r.jsx)("div",{className:"space-y-2",children:(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Disk Usage"}),(0,r.jsx)("span",{className:"text-lg font-bold text-green-600",children:(null==K||null==(R=K.current_usage)?void 0:R.disk_used_mb)?"".concat((K.current_usage.disk_used_mb/1024).toFixed(1)," GB"):"N/A"})]})})]}):(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)("p",{className:"text-gray-500",children:"Loading resource information..."})})]})}),(0,r.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,r.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Environmental Impact"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:[(0,r.jsxs)("div",{className:"bg-green-50 rounded-lg p-4 border border-green-200",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"CO₂ Emissions"}),(0,r.jsx)(u.fC,{className:"text-green-600",size:"sm"})]}),(0,r.jsx)("div",{className:"space-y-2",children:(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-2xl font-bold text-green-700",children:[(null==J?void 0:J.carbon_last_hour_grams)?(J.carbon_last_hour_grams/1e3).toFixed(3):"0.000"," kg"]}),(0,r.jsx)("p",{className:"text-xs text-gray-600",children:"Last hour total"})]})})]}),(0,r.jsxs)("div",{className:"bg-blue-50 rounded-lg p-4 border border-blue-200",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Energy Usage"}),(0,r.jsx)(u.xZ,{className:"text-blue-600",size:"sm"})]}),(0,r.jsx)("div",{className:"space-y-2",children:(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-2xl font-bold text-blue-700",children:[(null==J?void 0:J.energy_last_hour_kwh)?J.energy_last_hour_kwh.toFixed(4):"0.0000"," kWh"]}),(0,r.jsx)("p",{className:"text-xs text-gray-600",children:"Last hour total"})]})})]}),(0,r.jsxs)("div",{className:"bg-purple-50 rounded-lg p-4 border border-purple-200",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Estimated Cost"}),(0,r.jsx)(u.xm,{className:"text-purple-600",size:"sm"})]}),(0,r.jsx)("div",{className:"space-y-2",children:(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-2xl font-bold text-purple-700",children:["$",(null==J?void 0:J.cost_last_hour_cents)?(J.cost_last_hour_cents/100).toFixed(2):"0.00"]}),(0,r.jsx)("p",{className:"text-xs text-gray-600",children:"Last hour total"})]})})]})]}),(0,r.jsxs)("div",{className:"mt-6 border-t pt-4",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-3",children:"Token Usage Details"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,r.jsxs)("div",{className:"bg-gray-50 rounded p-3",children:[(0,r.jsx)("p",{className:"text-xs text-gray-600",children:"Total Tokens (24h)"}),(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-900",children:(null==J?void 0:J.tokens_24h)?J.tokens_24h.toLocaleString():"0"})]}),(0,r.jsxs)("div",{className:"bg-gray-50 rounded p-3",children:[(0,r.jsx)("p",{className:"text-xs text-gray-600",children:"Avg Tokens/Hour"}),(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-900",children:(null==J||null==(S=J.tokens_last_hour)?void 0:S.toLocaleString())||"0"})]}),(0,r.jsxs)("div",{className:"bg-gray-50 rounded p-3",children:[(0,r.jsx)("p",{className:"text-xs text-gray-600",children:"Model"}),(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-900",children:(null==q||null==(I=q.version)?void 0:I.includes("mock"))?"Mock LLM":"llama4scout"})]})]})]})]})}),(0,r.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("h3",{className:"text-lg font-medium text-gray-900",children:["Services Health",(null==H?void 0:H.services)?" (".concat(H.services.length," Services)"):""]}),(0,r.jsxs)("div",{className:"flex items-center space-x-4 text-sm",children:[(0,r.jsxs)("span",{className:"flex items-center",children:[(0,r.jsx)(u.md,{status:"green",className:"mr-1"}),"Healthy"]}),(0,r.jsxs)("span",{className:"flex items-center",children:[(0,r.jsx)(u.md,{status:"yellow",className:"mr-1"}),"Degraded"]}),(0,r.jsxs)("span",{className:"flex items-center",children:[(0,r.jsx)(u.md,{status:"red",className:"mr-1"}),"Unhealthy"]})]})]}),(null==H?void 0:H.services)?(0,r.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:H.services.map((e,t)=>(0,r.jsxs)("div",{className:"relative p-4 rounded-lg border-2 transition-all duration-200 hover:shadow-md ".concat(!0===e.healthy?"border-green-200 bg-green-50 hover:border-green-300":!0===e.available?"border-yellow-200 bg-yellow-50 hover:border-yellow-300":"border-red-200 bg-red-50 hover:border-red-300"),children:[(0,r.jsxs)("div",{className:"flex items-start justify-between",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-gray-900 truncate",children:B(e.name)}),(0,r.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:e.service_type})]}),(0,r.jsx)(u.md,{status:!0===e.healthy?"green":!0===e.available?"yellow":"red",className:"flex-shrink-0 ml-2"})]}),e.capabilities&&e.capabilities.length>0&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsxs)("p",{className:"text-xs text-gray-600",title:e.capabilities.join(", "),children:[e.capabilities.length," capabilities"]})})]},"".concat(e.name,"-").concat(t)))}):(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)("p",{className:"text-gray-500",children:"Loading services information..."})})]})}),O("ADMIN")&&(0,r.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,r.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Main Processor"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-5 sm:p-6 rounded-lg border-2 border-gray-200",children:[(0,r.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:"Processor Status"}),(0,r.jsx)("dd",{className:"mt-2",children:(0,r.jsx)("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-lg font-semibold ".concat((null==W?void 0:W.is_paused)?"bg-yellow-100 text-yellow-800":"bg-green-100 text-green-800"),children:(null==W?void 0:W.is_paused)?"PAUSED":"RUNNING"})})]}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-5 sm:p-6 rounded-lg border-2 border-gray-200",children:[(0,r.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:"Cognitive State"}),(0,r.jsx)("dd",{className:"mt-2 text-2xl font-semibold text-gray-900",children:(null==W?void 0:W.cognitive_state)||"WORK"})]}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-5 sm:p-6 rounded-lg border-2 border-gray-200",children:[(0,r.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:"Queue Depth"}),(0,r.jsx)("dd",{className:"mt-2 text-2xl font-semibold text-gray-900",children:(null==W?void 0:W.queue_depth)||0})]}),(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-5 sm:p-6 rounded-lg border-2 border-gray-200",children:[(0,r.jsx)("dt",{className:"text-sm font-medium text-gray-500",children:"Actions"}),(0,r.jsx)("dd",{className:"mt-2",children:(null==W?void 0:W.is_paused)?(0,r.jsx)("button",{onClick:()=>L({type:"resumeRuntime"}),className:"inline-flex items-center px-3 py-1 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-green-600 hover:bg-green-700",children:"Resume"}):(0,r.jsx)("button",{onClick:()=>L({type:"pauseRuntime"}),className:"inline-flex items-center px-3 py-1 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-yellow-600 hover:bg-yellow-700",children:"Pause"})})]})]}),(0,r.jsx)("div",{className:"mt-4 p-4 bg-blue-50 rounded-lg",children:(0,r.jsxs)("p",{className:"text-sm text-blue-800",children:[(0,r.jsx)("strong",{children:"Note:"})," The CIRIS system has one main processor that cycles through cognitive states (WAKEUP, WORK, PLAY, DREAM, SOLITUDE, SHUTDOWN). Pausing affects the entire processor, not individual states."]})})]})}),O("ADMIN")&&(0,r.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,r.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Register New Adapter"}),(0,r.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,r.jsxs)("select",{value:"",onChange:e=>{let t=e.target.value;console.log("Adapter selected:",t),t&&(F({type:t}),"discord"===t?D({bot_token:"",server_id:"",monitored_channel_ids:[],home_channel_id:"",deferral_channel_id:"",respond_to_mentions:!0,respond_to_dms:!0}):"api"===t?D({host:"0.0.0.0",port:8080,cors_origins:["*"],enable_auth:!0}):"cli"===t&&D({prompt:"> ",enable_colors:!0,history_file:".ciris_history"}))},className:"block w-full max-w-xs px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm",children:[(0,r.jsx)("option",{value:"",children:"Select adapter type..."}),(0,r.jsx)("option",{value:"api",children:"API"}),(0,r.jsx)("option",{value:"cli",children:"CLI"}),(0,r.jsx)("option",{value:"discord",children:"Discord"})]}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Select an adapter type to register a new instance"})]})]})}),(0,r.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,r.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Active Communication Channels"}),G&&G.length>0?(0,r.jsx)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:G.map(e=>(0,r.jsxs)("div",{className:"relative p-4 rounded-lg border-2 border-gray-200 bg-gray-50 hover:shadow-md transition-all duration-200",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-gray-900",children:e.display_name}),(0,r.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",e.channel_id]}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["Type: ",e.channel_type]})]}),(0,r.jsx)(u.md,{status:e.is_active?"green":"gray",className:"flex-shrink-0 ml-2"})]}),(0,r.jsxs)("div",{className:"mt-3 space-y-1",children:[(0,r.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Messages:"}),(0,r.jsx)("span",{className:"font-medium",children:e.message_count||0})]}),e.last_activity&&(0,r.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Last Activity:"}),(0,r.jsx)("span",{className:"font-medium",children:new Date(e.last_activity).toLocaleTimeString()})]})]})]},e.channel_id))}):(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)("p",{className:"text-gray-500",children:"No active channels found"})})]})}),O("ADMIN")&&(null==V?void 0:V.adapters)&&V.adapters.length>0&&(0,r.jsx)("div",{className:"bg-white shadow rounded-lg",children:(0,r.jsxs)("div",{className:"px-4 py-5 sm:p-6",children:[(0,r.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Adapter Management"}),(0,r.jsx)("div",{className:"overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg",children:(0,r.jsxs)("table",{className:"min-w-full divide-y divide-gray-300",children:[(0,r.jsx)("thead",{className:"bg-gray-50",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"px-3 py-3.5 text-left text-sm font-semibold text-gray-900",children:"Adapter Name"}),(0,r.jsx)("th",{scope:"col",className:"px-3 py-3.5 text-left text-sm font-semibold text-gray-900",children:"Type"}),(0,r.jsx)("th",{scope:"col",className:"px-3 py-3.5 text-left text-sm font-semibold text-gray-900",children:"Status"}),(0,r.jsx)("th",{scope:"col",className:"px-3 py-3.5 text-left text-sm font-semibold text-gray-900",children:"Active Channels"}),(0,r.jsx)("th",{scope:"col",className:"relative py-3.5 pl-3 pr-4 sm:pr-6",children:(0,r.jsx)("span",{className:"sr-only",children:"Actions"})})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-gray-200 bg-white",children:V.adapters.map(e=>{var t,s;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"whitespace-nowrap px-3 py-4 text-sm font-medium text-gray-900",children:e.adapter_id}),(0,r.jsx)("td",{className:"whitespace-nowrap px-3 py-4 text-sm text-gray-500",children:e.adapter_type}),(0,r.jsx)("td",{className:"whitespace-nowrap px-3 py-4 text-sm",children:(0,r.jsx)("span",{className:"inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ".concat("api"===e.adapter_type&&(null==q?void 0:q.status)==="healthy"||e.is_running?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"),children:"api"===e.adapter_type&&(null==q?void 0:q.status)==="healthy"||e.is_running?"Active":"Loaded"})}),(0,r.jsx)("td",{className:"whitespace-nowrap px-3 py-4 text-sm text-gray-500",children:(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsxs)("span",{className:"font-medium",children:[(null==G?void 0:G.filter(t=>t.channel_type===e.adapter_type).length)||0," active"]}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:(null==G||null==(s=G.filter(t=>t.channel_type===e.adapter_type))||null==(t=s.map(e=>e.display_name))?void 0:t.join(", "))||"No active channels"})]})}),(0,r.jsx)("td",{className:"relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6",children:(0,r.jsxs)("div",{className:"flex items-center justify-end space-x-3",children:[(0,r.jsx)("button",{onClick:()=>{let t="adapter.".concat(e.adapter_id,".config");o.AQ.config.getConfigByKey(t).then(t=>{t&&t.value?D(t.value):D({}),F({type:e.adapter_type,adapterId:e.adapter_id,isEdit:!0})}).catch(e=>{console.error("Failed to fetch adapter config:",e),c.Ay.error("Failed to load adapter configuration")})},className:"text-indigo-600 hover:text-indigo-900",children:"Edit"}),(0,r.jsx)("button",{onClick:()=>L({type:"reloadAdapter",name:e.adapter_id}),className:"text-blue-600 hover:text-blue-900",children:"Reload"}),(0,r.jsx)("button",{onClick:()=>L({type:"unregisterAdapter",name:e.adapter_id}),className:"text-red-600 hover:text-red-900",children:"Remove"})]})})]},e.adapter_id)})})]})})]})}),E&&"registerAdapter"===E.type&&"test"===E.name&&(0,r.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",zIndex:9999},children:(0,r.jsxs)("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",backgroundColor:"white",padding:"20px",borderRadius:"8px"},children:[(0,r.jsx)("h2",{children:"Test Modal Works!"}),(0,r.jsx)("button",{onClick:()=>L(null),style:{marginTop:"10px",padding:"5px 10px"},children:"Close"})]})}),E&&"test"!==E.name?(0,r.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",zIndex:9999},children:(0,r.jsxs)("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",backgroundColor:"white",padding:"30px",borderRadius:"8px",maxWidth:"500px",width:"90%"},children:[(0,r.jsx)("h3",{style:{fontSize:"18px",fontWeight:"bold",marginBottom:"15px"},children:"Confirm Action"}),(0,r.jsxs)("p",{style:{marginBottom:"20px",color:"#666"},children:["pauseRuntime"===E.type&&"Are you sure you want to pause the runtime? This will temporarily stop all message processing.","resumeRuntime"===E.type&&"Are you sure you want to resume the runtime? Message processing will continue.","reloadAdapter"===E.type&&"Are you sure you want to reload the ".concat(E.name," adapter?"),"unregisterAdapter"===E.type&&"Are you sure you want to remove the ".concat(E.name," adapter? This cannot be undone."),"registerAdapter"===E.type&&"Are you sure you want to register a new ".concat(E.name," adapter?")]}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[(0,r.jsx)("button",{onClick:()=>L(null),style:{padding:"8px 16px",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:"white",cursor:"pointer"},children:"Cancel"}),(0,r.jsx)("button",{onClick:()=>{if(E){switch(E.type){case"pauseRuntime":Y.mutate();break;case"resumeRuntime":$.mutate();break;case"pauseProcessor":E.name&&Z.mutate({name:E.name});break;case"resumeProcessor":E.name&&X.mutate(E.name);break;case"reloadAdapter":E.name&&ee.mutate(E.name);break;case"unregisterAdapter":E.name&&et.mutate(E.name);break;case"registerAdapter":E.name&&es.mutate({adapterType:E.name})}L(null)}},style:{padding:"8px 16px",backgroundColor:"#f59e0b",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Confirm"})]})]})}):null,P&&(0,r.jsx)(h,{adapterType:P.type,adapterId:P.adapterId,isEdit:P.isEdit,config:T,setConfig:D,onSubmit:(e,t)=>{if(P.isEdit&&P.adapterId){let e="adapter.".concat(P.adapterId,".config");o.AQ.config.updateConfigByKey(e,t).then(()=>{c.Ay.success("Adapter configuration updated"),z.invalidateQueries({queryKey:["system-adapters"]}),F(null),D({})}).catch(e=>{c.Ay.error("Failed to update adapter configuration")})}else es.mutate({adapterType:e,config:t})},onClose:()=>{F(null),D({})},isPending:es.isPending})]})}},6258:(e,t,s)=>{"use strict";s.d(t,{n:()=>c});var r=s(7620),a=s(589),i=s(494),n=s(2327),l=s(7703),o=class extends n.Q{#a;#i=void 0;#n;#l;constructor(e,t){super(),this.#a=e,this.setOptions(t),this.bindMethods(),this.#o()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#a.defaultMutationOptions(e),(0,l.f8)(this.options,t)||this.#a.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,l.EN)(t.mutationKey)!==(0,l.EN)(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#o(),this.#d(e)}getCurrentResult(){return this.#i}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#o(),this.#d()}mutate(e,t){return this.#l=t,this.#n?.removeObserver(this),this.#n=this.#a.getMutationCache().build(this.#a,this.options),this.#n.addObserver(this),this.#n.execute(e)}#o(){let e=this.#n?.state??(0,a.$)();this.#i={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#d(e){i.jG.batch(()=>{if(this.#l&&this.hasListeners()){let t=this.#i.variables,s=this.#i.context;e?.type==="success"?(this.#l.onSuccess?.(e.data,t,s),this.#l.onSettled?.(e.data,null,t,s)):e?.type==="error"&&(this.#l.onError?.(e.error,t,s),this.#l.onSettled?.(void 0,e.error,t,s))}this.listeners.forEach(e=>{e(this.#i)})})}},d=s(7606);function c(e,t){let s=(0,d.jE)(t),[a]=r.useState(()=>new o(s,e));r.useEffect(()=>{a.setOptions(e)},[a,e]);let n=r.useSyncExternalStore(r.useCallback(e=>a.subscribe(i.jG.batchCalls(e)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),c=r.useCallback((e,t)=>{a.mutate(e,t).catch(l.lQ)},[a]);if(n.error&&(0,l.GU)(a.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:c,mutateAsync:n.mutate}}}},e=>{var t=t=>e(e.s=t);e.O(0,[4534,8903,3297,704,9484,587,8315,7358],()=>t(739)),_N_E=e.O()}]); | |||
| @@ -0,0 +1 @@ | |||
| "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8072],{444:(e,t)=>{function r(e){let t={};for(let[r,n]of e.entries()){let e=t[r];void 0===e?t[r]=n:Array.isArray(e)?e.push(n):t[r]=[e,n]}return t}function n(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function o(e){let t=new URLSearchParams;for(let[r,o]of Object.entries(e))if(Array.isArray(o))for(let e of o)t.append(r,n(e));else t.set(r,n(o));return t}function u(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(let t of r){for(let r of t.keys())e.delete(r);for(let[r,n]of t.entries())e.append(r,n)}return e}Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{assign:function(){return u},searchParamsToUrlQuery:function(){return r},urlQueryToSearchParams:function(){return o}})},2942:(e,t,r)=>{var n=r(2418);r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(t,{useSearchParams:function(){return n.useSearchParams}})},4637:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isLocalURL",{enumerable:!0,get:function(){return u}});let n=r(8490),o=r(1075);function u(e){if(!(0,n.isAbsoluteUrl)(e))return!0;try{let t=(0,n.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,o.hasBasePath)(r.pathname)}catch(e){return!1}}},5908:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{formatUrl:function(){return u},formatWithValidation:function(){return i},urlObjectKeys:function(){return a}});let n=r(3378)._(r(444)),o=/https?|ftp|gopher|file/;function u(e){let{auth:t,hostname:r}=e,u=e.protocol||"",a=e.pathname||"",i=e.hash||"",l=e.query||"",f=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?f=t+e.host:r&&(f=t+(~r.indexOf(":")?"["+r+"]":r),e.port&&(f+=":"+e.port)),l&&"object"==typeof l&&(l=String(n.urlQueryToSearchParams(l)));let c=e.search||l&&"?"+l||"";return u&&!u.endsWith(":")&&(u+=":"),e.slashes||(!u||o.test(u))&&!1!==f?(f="//"+(f||""),a&&"/"!==a[0]&&(a="/"+a)):f||(f=""),i&&"#"!==i[0]&&(i="#"+i),c&&"?"!==c[0]&&(c="?"+c),""+u+f+(a=a.replace(/[?#]/g,encodeURIComponent))+(c=c.replace("#","%23"))+i}let a=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function i(e){return u(e)}},6355:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"errorOnce",{enumerable:!0,get:function(){return r}});let r=e=>{}},7261:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{default:function(){return g},useLinkStatus:function(){return b}});let n=r(3378),o=r(4568),u=n._(r(7620)),a=r(5908),i=r(9330),l=r(7533),f=r(7849),c=r(8490),s=r(7720);r(1611);let p=r(3781),d=r(4637),h=r(529);function y(e){return"string"==typeof e?e:(0,a.formatUrl)(e)}function g(e){let t,r,n,[a,g]=(0,u.useOptimistic)(p.IDLE_LINK_STATUS),b=(0,u.useRef)(null),{href:P,as:_,children:v,prefetch:E=null,passHref:O,replace:j,shallow:S,scroll:T,onClick:C,onMouseEnter:N,onTouchStart:A,legacyBehavior:L=!1,onNavigate:R,ref:x,unstable_dynamicOnHover:M,...U}=e;t=v,L&&("string"==typeof t||"number"==typeof t)&&(t=(0,o.jsx)("a",{children:t}));let k=u.default.useContext(i.AppRouterContext),I=!1!==E,w=null===E?l.PrefetchKind.AUTO:l.PrefetchKind.FULL,{href:D,as:F}=u.default.useMemo(()=>{let e=y(P);return{href:e,as:_?y(_):e}},[P,_]);L&&(r=u.default.Children.only(t));let K=L?r&&"object"==typeof r&&r.ref:x,B=u.default.useCallback(e=>(null!==k&&(b.current=(0,p.mountLinkInstance)(e,D,k,w,I,g)),()=>{b.current&&((0,p.unmountLinkForCurrentNavigation)(b.current),b.current=null),(0,p.unmountPrefetchableInstance)(e)}),[I,D,k,w,g]),z={ref:(0,f.useMergedRef)(B,K),onClick(e){L||"function"!=typeof C||C(e),L&&r.props&&"function"==typeof r.props.onClick&&r.props.onClick(e),k&&(e.defaultPrevented||function(e,t,r,n,o,a,i){let{nodeName:l}=e.currentTarget;if(!("A"===l.toUpperCase()&&function(e){let t=e.currentTarget.getAttribute("target");return t&&"_self"!==t||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||e.currentTarget.hasAttribute("download"))){if(!(0,d.isLocalURL)(t)){o&&(e.preventDefault(),location.replace(t));return}e.preventDefault(),u.default.startTransition(()=>{if(i){let e=!1;if(i({preventDefault:()=>{e=!0}}),e)return}(0,h.dispatchNavigateAction)(r||t,o?"replace":"push",null==a||a,n.current)})}}(e,D,F,b,j,T,R))},onMouseEnter(e){L||"function"!=typeof N||N(e),L&&r.props&&"function"==typeof r.props.onMouseEnter&&r.props.onMouseEnter(e),k&&I&&(0,p.onNavigationIntent)(e.currentTarget,!0===M)},onTouchStart:function(e){L||"function"!=typeof A||A(e),L&&r.props&&"function"==typeof r.props.onTouchStart&&r.props.onTouchStart(e),k&&I&&(0,p.onNavigationIntent)(e.currentTarget,!0===M)}};return(0,c.isAbsoluteUrl)(F)?z.href=F:L&&!O&&("a"!==r.type||"href"in r.props)||(z.href=(0,s.addBasePath)(F)),n=L?u.default.cloneElement(r,z):(0,o.jsx)("a",{...U,...z,children:t}),(0,o.jsx)(m.Provider,{value:a,children:n})}r(6355);let m=(0,u.createContext)(p.IDLE_LINK_STATUS),b=()=>(0,u.useContext)(m);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7849:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"useMergedRef",{enumerable:!0,get:function(){return o}});let n=r(7620);function o(e,t){let r=(0,n.useRef)(null),o=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=o.current;t&&(o.current=null,t())}else e&&(r.current=u(e,n)),t&&(o.current=u(t,n))},[e,t])}function u(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8490:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{DecodeError:function(){return h},MiddlewareNotFoundError:function(){return b},MissingStaticPage:function(){return m},NormalizeError:function(){return y},PageNotFoundError:function(){return g},SP:function(){return p},ST:function(){return d},WEB_VITALS:function(){return r},execOnce:function(){return n},getDisplayName:function(){return l},getLocationOrigin:function(){return a},getURL:function(){return i},isAbsoluteUrl:function(){return u},isResSent:function(){return f},loadGetInitialProps:function(){return s},normalizeRepeatedSlashes:function(){return c},stringifyError:function(){return P}});let r=["CLS","FCP","FID","INP","LCP","TTFB"];function n(e){let t,r=!1;return function(){for(var n=arguments.length,o=Array(n),u=0;u<n;u++)o[u]=arguments[u];return r||(r=!0,t=e(...o)),t}}let o=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,u=e=>o.test(e);function a(){let{protocol:e,hostname:t,port:r}=window.location;return e+"//"+t+(r?":"+r:"")}function i(){let{href:e}=window.location,t=a();return e.substring(t.length)}function l(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function f(e){return e.finished||e.headersSent}function c(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?"?"+t.slice(1).join("?"):"")}async function s(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await s(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&f(r))return n;if(!n)throw Object.defineProperty(Error('"'+l(e)+'.getInitialProps()" should resolve to an object. But found "'+n+'" instead.'),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return n}let p="undefined"!=typeof performance,d=p&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class h extends Error{}class y extends Error{}class g extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message="Cannot find module for page: "+e}}class m extends Error{constructor(e,t){super(),this.message="Failed to load static file for page: "+e+" "+t}}class b extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function P(e){return JSON.stringify({message:e.message,stack:e.stack})}}}]); | |||
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High
Copilot Autofix
AI 15 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| @@ -0,0 +1 @@ | |||
| "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8072],{444:(e,t)=>{function r(e){let t={};for(let[r,n]of e.entries()){let e=t[r];void 0===e?t[r]=n:Array.isArray(e)?e.push(n):t[r]=[e,n]}return t}function n(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function o(e){let t=new URLSearchParams;for(let[r,o]of Object.entries(e))if(Array.isArray(o))for(let e of o)t.append(r,n(e));else t.set(r,n(o));return t}function u(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(let t of r){for(let r of t.keys())e.delete(r);for(let[r,n]of t.entries())e.append(r,n)}return e}Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{assign:function(){return u},searchParamsToUrlQuery:function(){return r},urlQueryToSearchParams:function(){return o}})},2942:(e,t,r)=>{var n=r(2418);r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(t,{useSearchParams:function(){return n.useSearchParams}})},4637:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isLocalURL",{enumerable:!0,get:function(){return u}});let n=r(8490),o=r(1075);function u(e){if(!(0,n.isAbsoluteUrl)(e))return!0;try{let t=(0,n.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,o.hasBasePath)(r.pathname)}catch(e){return!1}}},5908:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{formatUrl:function(){return u},formatWithValidation:function(){return i},urlObjectKeys:function(){return a}});let n=r(3378)._(r(444)),o=/https?|ftp|gopher|file/;function u(e){let{auth:t,hostname:r}=e,u=e.protocol||"",a=e.pathname||"",i=e.hash||"",l=e.query||"",f=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?f=t+e.host:r&&(f=t+(~r.indexOf(":")?"["+r+"]":r),e.port&&(f+=":"+e.port)),l&&"object"==typeof l&&(l=String(n.urlQueryToSearchParams(l)));let c=e.search||l&&"?"+l||"";return u&&!u.endsWith(":")&&(u+=":"),e.slashes||(!u||o.test(u))&&!1!==f?(f="//"+(f||""),a&&"/"!==a[0]&&(a="/"+a)):f||(f=""),i&&"#"!==i[0]&&(i="#"+i),c&&"?"!==c[0]&&(c="?"+c),""+u+f+(a=a.replace(/[?#]/g,encodeURIComponent))+(c=c.replace("#","%23"))+i}let a=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function i(e){return u(e)}},6355:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"errorOnce",{enumerable:!0,get:function(){return r}});let r=e=>{}},7261:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{default:function(){return g},useLinkStatus:function(){return b}});let n=r(3378),o=r(4568),u=n._(r(7620)),a=r(5908),i=r(9330),l=r(7533),f=r(7849),c=r(8490),s=r(7720);r(1611);let p=r(3781),d=r(4637),h=r(529);function y(e){return"string"==typeof e?e:(0,a.formatUrl)(e)}function g(e){let t,r,n,[a,g]=(0,u.useOptimistic)(p.IDLE_LINK_STATUS),b=(0,u.useRef)(null),{href:P,as:_,children:v,prefetch:E=null,passHref:O,replace:j,shallow:S,scroll:T,onClick:C,onMouseEnter:N,onTouchStart:A,legacyBehavior:L=!1,onNavigate:R,ref:x,unstable_dynamicOnHover:M,...U}=e;t=v,L&&("string"==typeof t||"number"==typeof t)&&(t=(0,o.jsx)("a",{children:t}));let k=u.default.useContext(i.AppRouterContext),I=!1!==E,w=null===E?l.PrefetchKind.AUTO:l.PrefetchKind.FULL,{href:D,as:F}=u.default.useMemo(()=>{let e=y(P);return{href:e,as:_?y(_):e}},[P,_]);L&&(r=u.default.Children.only(t));let K=L?r&&"object"==typeof r&&r.ref:x,B=u.default.useCallback(e=>(null!==k&&(b.current=(0,p.mountLinkInstance)(e,D,k,w,I,g)),()=>{b.current&&((0,p.unmountLinkForCurrentNavigation)(b.current),b.current=null),(0,p.unmountPrefetchableInstance)(e)}),[I,D,k,w,g]),z={ref:(0,f.useMergedRef)(B,K),onClick(e){L||"function"!=typeof C||C(e),L&&r.props&&"function"==typeof r.props.onClick&&r.props.onClick(e),k&&(e.defaultPrevented||function(e,t,r,n,o,a,i){let{nodeName:l}=e.currentTarget;if(!("A"===l.toUpperCase()&&function(e){let t=e.currentTarget.getAttribute("target");return t&&"_self"!==t||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||e.currentTarget.hasAttribute("download"))){if(!(0,d.isLocalURL)(t)){o&&(e.preventDefault(),location.replace(t));return}e.preventDefault(),u.default.startTransition(()=>{if(i){let e=!1;if(i({preventDefault:()=>{e=!0}}),e)return}(0,h.dispatchNavigateAction)(r||t,o?"replace":"push",null==a||a,n.current)})}}(e,D,F,b,j,T,R))},onMouseEnter(e){L||"function"!=typeof N||N(e),L&&r.props&&"function"==typeof r.props.onMouseEnter&&r.props.onMouseEnter(e),k&&I&&(0,p.onNavigationIntent)(e.currentTarget,!0===M)},onTouchStart:function(e){L||"function"!=typeof A||A(e),L&&r.props&&"function"==typeof r.props.onTouchStart&&r.props.onTouchStart(e),k&&I&&(0,p.onNavigationIntent)(e.currentTarget,!0===M)}};return(0,c.isAbsoluteUrl)(F)?z.href=F:L&&!O&&("a"!==r.type||"href"in r.props)||(z.href=(0,s.addBasePath)(F)),n=L?u.default.cloneElement(r,z):(0,o.jsx)("a",{...U,...z,children:t}),(0,o.jsx)(m.Provider,{value:a,children:n})}r(6355);let m=(0,u.createContext)(p.IDLE_LINK_STATUS),b=()=>(0,u.useContext)(m);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7849:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"useMergedRef",{enumerable:!0,get:function(){return o}});let n=r(7620);function o(e,t){let r=(0,n.useRef)(null),o=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=o.current;t&&(o.current=null,t())}else e&&(r.current=u(e,n)),t&&(o.current=u(t,n))},[e,t])}function u(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8490:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{DecodeError:function(){return h},MiddlewareNotFoundError:function(){return b},MissingStaticPage:function(){return m},NormalizeError:function(){return y},PageNotFoundError:function(){return g},SP:function(){return p},ST:function(){return d},WEB_VITALS:function(){return r},execOnce:function(){return n},getDisplayName:function(){return l},getLocationOrigin:function(){return a},getURL:function(){return i},isAbsoluteUrl:function(){return u},isResSent:function(){return f},loadGetInitialProps:function(){return s},normalizeRepeatedSlashes:function(){return c},stringifyError:function(){return P}});let r=["CLS","FCP","FID","INP","LCP","TTFB"];function n(e){let t,r=!1;return function(){for(var n=arguments.length,o=Array(n),u=0;u<n;u++)o[u]=arguments[u];return r||(r=!0,t=e(...o)),t}}let o=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,u=e=>o.test(e);function a(){let{protocol:e,hostname:t,port:r}=window.location;return e+"//"+t+(r?":"+r:"")}function i(){let{href:e}=window.location,t=a();return e.substring(t.length)}function l(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function f(e){return e.finished||e.headersSent}function c(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?"?"+t.slice(1).join("?"):"")}async function s(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await s(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&f(r))return n;if(!n)throw Object.defineProperty(Error('"'+l(e)+'.getInitialProps()" should resolve to an object. But found "'+n+'" instead.'),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return n}let p="undefined"!=typeof performance,d=p&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class h extends Error{}class y extends Error{}class g extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message="Cannot find module for page: "+e}}class m extends Error{constructor(e,t){super(),this.message="Failed to load static file for page: "+e+" "+t}}class b extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function P(e){return JSON.stringify({message:e.message,stack:e.stack})}}}]); | |||
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High
Copilot Autofix
AI 15 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| @@ -123,13 +128,17 @@ | |||
| llm_model: Model name | |||
| agent_port: Port for agent API (default: 8080) | |||
| """ | |||
| # Log what we received for debugging | |||
| logger.info(f"[create_env_file] Received llm_provider='{llm_provider}', llm_base_url='{llm_base_url}'") | |||
|
|
|||
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix this error, avoid logging data that may have originated from potentially sensitive user input during interactive setup, especially anything that could plausibly include API keys, secrets, passwords, or tokens. In the indicated log line at create_env_file, the information logged is the LLM provider and base URL. While these are less likely to be sensitive, user input for "base URL" could technically include a secret if mis-pasted, or practices might change in the future. Therefore, the best solution is to remove or strictly limit this logging statement, ensuring no user input is written directly to logs. Specifically, remove or sanitize the log line at line 132 in create_env_file. No other code changes or imports are required.
| @@ -129,7 +129,6 @@ | ||
| agent_port: Port for agent API (default: 8080) | ||
| """ | ||
| # Log what we received for debugging | ||
| logger.info(f"[create_env_file] Received llm_provider='{llm_provider}', llm_base_url='{llm_base_url}'") | ||
|
|
||
| # Generate encryption keys | ||
| secrets_key = generate_encryption_key() |
| " New key: %s\n" | ||
| " Circuit breaker state: %s", | ||
| old_key_preview, | ||
| new_key_preview, |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To remediate the risk of clear-text logging of sensitive information, we should ensure that no part of the API key (old or new) is logged, even in truncated form. In update_api_key, we should avoid computing or passing old_key_preview and new_key_preview, and omit them from the logger.info statement. Instead, the log should state that the API key was updated and the circuit breaker reset, along with the state of the circuit breaker, but without including any (even partial) API key data. Only safe, non-sensitive metadata should be logged.
What to change:
- In
update_api_key, lines 202–225:- Remove creation and logging of
old_key_previewandnew_key_preview(old_key_preview,new_key_preview) - Edit the relevant
logger.infocall so the log message omits both previews and only logs non-sensitive data (e.g., the fact the key changed, and the circuit breaker state). - Ensure that the rest of the function is unchanged.
- Remove creation and logging of
No new imports or methods are required; only logging statements need to be made safer.
| @@ -199,8 +199,7 @@ | ||
| logger.warning("[LLM_TOKEN] Attempted to update with empty API key - ignoring") | ||
| return | ||
|
|
||
| old_key_preview = self.openai_config.api_key[:20] + "..." if self.openai_config.api_key else "None" | ||
| new_key_preview = new_api_key[:20] + "..." | ||
| # Do not log any part of the API key for security | ||
|
|
||
| # Update config | ||
| self.openai_config.api_key = new_api_key | ||
| @@ -217,12 +216,7 @@ | ||
| self.circuit_breaker.reset() | ||
|
|
||
| logger.info( | ||
| "[LLM_TOKEN] API key updated and circuit breaker reset:\n" | ||
| " Old key: %s\n" | ||
| " New key: %s\n" | ||
| " Circuit breaker state: %s", | ||
| old_key_preview, | ||
| new_key_preview, | ||
| "[LLM_TOKEN] API key updated and circuit breaker reset. Circuit breaker state: %s", | ||
| self.circuit_breaker.get_stats().get("state", "unknown"), | ||
| ) | ||
|
|
| " Old key: %s\n" | ||
| " New key: %s\n" | ||
| " Circuit breaker state: %s", | ||
| old_key_preview, |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
The correct fix is to ensure that API keys are never written to the logs, not even partially masked or previewed. To maintain some ability to distinguish which key was replaced (if absolutely needed), log only non-sensitive distinguishing information such as "***" or "REDACTED" for both old and new key. Remove the previews completely. Only generic log statements should indicate that the key was updated; never log any characters of the credentials themselves.
Implement this by:
- Removing the
old_key_previewandnew_key_previewvariables and their usage in the logger call. - Replace the log line so that, instead of interpolating the key preview values, it either logs
"REDACTED"or omits the old/new key from the log message entirely. - Only the circuit breaker state is logged, since it's not sensitive information.
Edit can be made directly at lines 202–227 of ciris_engine/logic/services/runtime/llm_service/service.py in the update_api_key method.
No new imports or dependencies are needed.
| @@ -199,9 +199,6 @@ | ||
| logger.warning("[LLM_TOKEN] Attempted to update with empty API key - ignoring") | ||
| return | ||
|
|
||
| old_key_preview = self.openai_config.api_key[:20] + "..." if self.openai_config.api_key else "None" | ||
| new_key_preview = new_api_key[:20] + "..." | ||
|
|
||
| # Update config | ||
| self.openai_config.api_key = new_api_key | ||
|
|
||
| @@ -217,12 +214,7 @@ | ||
| self.circuit_breaker.reset() | ||
|
|
||
| logger.info( | ||
| "[LLM_TOKEN] API key updated and circuit breaker reset:\n" | ||
| " Old key: %s\n" | ||
| " New key: %s\n" | ||
| " Circuit breaker state: %s", | ||
| old_key_preview, | ||
| new_key_preview, | ||
| "[LLM_TOKEN] API key updated and circuit breaker reset. Circuit breaker state: %s", | ||
| self.circuit_breaker.get_stats().get("state", "unknown"), | ||
| ) | ||
|
|
| raise HTTPException( | ||
| status_code=status.HTTP_400_BAD_REQUEST, detail="System admin password must be at least 8 characters" | ||
| ) | ||
| # Validate passwords and potentially generate for OAuth users |
Check failure
Code scanning / CodeQL
Clear-text storage of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the issue, we should not write sensitive information in clear-text to the .env file. There are two general approaches:
- Encrypt the sensitive value before writing, and require the application to be able to decrypt it when it needs to use it (providing a decryption key at runtime via environment variable, secret manager, etc).
- Omit the sensitive information from the config file entirely, requiring the operator to place it securely elsewhere (such as a secure environment variable manager, etc).
To preserve current functionality with minimal disruption, we will encrypt the API key value before writing it to the config file, using the standard cryptography library (Fernet symmetric encryption). This requires adding an import, ensuring there is an encryption key (which can be generated and stored separately or provided as an argument), and updating both the storing and (eventually) retrieval logic to deal with decryption.
Within the shown code, all relevant logic is in the _save_setup_config function (line 814 onwards). We'll:
- Add a Fernet key loading/generation function, or use an existing one if present (
generate_encryption_keyis imported; perhaps it's relevant). - Encrypt
setup.backup_llm_api_keybefore writing. - Prefix/write the encrypted value clearly (e.g.
ENCRYPTED:) to make decryption straightforward. - Ensure the encryption key is not stored side-by-side with the file.
This requires:
- Adding the necessary
from cryptography.fernet import Fernetimport. - Ensuring we have a Fernet key from the environment or available config.
- Encrypting/encoding the API key before writing.
| @@ -13,6 +13,7 @@ | ||
| from pathlib import Path | ||
| from typing import Any, Dict, List, Optional | ||
|
|
||
| from cryptography.fernet import Fernet | ||
| from fastapi import APIRouter, Depends, HTTPException, Request, status | ||
| from pydantic import BaseModel, Field | ||
|
|
||
| @@ -824,6 +825,19 @@ | ||
| llm_base_url = setup.llm_base_url or "" | ||
| llm_model = setup.llm_model or "" | ||
|
|
||
| # Obtain encryption key (use existing generate_encryption_key or from env) | ||
| # For demonstration, load/create a key (in real usage, should be securely stored/retrieved) | ||
| # This is just for demonstration; replace with real key management in production | ||
| encryption_key_path = Path(os.environ.get("CIRIS_ENCRYPTION_KEY_PATH", ".fernet.key")) | ||
| if encryption_key_path.exists(): | ||
| with open(encryption_key_path, "rb") as key_file: | ||
| encryption_key = key_file.read() | ||
| else: | ||
| encryption_key = generate_encryption_key() | ||
| with open(encryption_key_path, "wb") as key_file: | ||
| key_file.write(encryption_key) | ||
| fernet = Fernet(encryption_key) | ||
|
|
||
| # Create .env file using existing wizard logic | ||
| create_env_file( | ||
| save_path=config_path, | ||
| @@ -854,7 +868,9 @@ | ||
| # Backup/Secondary LLM Configuration (Optional) | ||
| if setup.backup_llm_api_key: | ||
| f.write("\n# Backup/Secondary LLM Configuration\n") | ||
| f.write(f'CIRIS_OPENAI_API_KEY_2="{setup.backup_llm_api_key}"\n') | ||
| # Encrypt the API key before writing to config | ||
| encrypted_api_key = fernet.encrypt(setup.backup_llm_api_key.encode()).decode() | ||
| f.write(f'CIRIS_OPENAI_API_KEY_2="ENCRYPTED:{encrypted_api_key}"\n') | ||
| if setup.backup_llm_base_url: | ||
| f.write(f'CIRIS_OPENAI_API_BASE_2="{setup.backup_llm_base_url}"\n') | ||
| if setup.backup_llm_model: |
| Supports two authentication modes: | ||
| 1. Server mode: Uses CIRIS_BILLING_API_KEY (agents.ciris.ai) | ||
| 2. JWT pass-through: Uses Bearer token from request (Android/native) | ||
|
|
||
| Only works when CIRISBillingProvider is configured. |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
The best fix is to ensure that the log on lines 641–648 does not leak any sensitive information. Specifically, avoid logging values that include or would reveal:
- OAuth provider identifiers (as these may uniquely identify users or partners)
- OAuth external IDs or any user identifier (wa_id, external_id)
- Anything related directly to specific tokens or emails
Instead, only log non-sensitive, non-identifying metadata: e.g., whether certain required fields are present (not their values), what optional parameters are included (as booleans), or simply the fact that a request is being made with certain limits/offsets.
Thus, alter the log message to redact the values or log only the presence/status of required fields rather than their values. Make the new log message explicit that it avoids sensitive content, as was already being done for emails but not for the other fields.
Regions to change:
Within ciris_engine/logic/adapters/api/routes/billing.py, replace only the debug log on lines 641–648.
No import changes are required.
No need for new methods/definitions.
| @@ -638,13 +638,14 @@ | ||
| if tenant_id: | ||
| params["tenant_id"] = str(tenant_id) | ||
|
|
||
| # Log request details for debugging (without PII) | ||
| # Log request details for debugging (WITH NO sensitive data: only presence/absence, not values) | ||
| logger.debug( | ||
| f"[BILLING_TRANSACTIONS] Request to billing backend: " | ||
| f"oauth_provider={params.get('oauth_provider')}, " | ||
| f"external_id={params.get('external_id')}, " | ||
| f"wa_id={params.get('wa_id')}, " | ||
| f"has_email={user_identity.get('customer_email') is not None}" | ||
| "[BILLING_TRANSACTIONS] Request to billing backend: " + | ||
| f"has_oauth_provider={'oauth_provider' in params and params.get('oauth_provider') is not None}, " | ||
| f"has_external_id={'external_id' in params and params.get('external_id') is not None}, " | ||
| f"has_wa_id={'wa_id' in params and params.get('wa_id') is not None}, " | ||
| f"has_email={user_identity.get('customer_email') is not None}, " | ||
| f"limit={params.get('limit')}, offset={params.get('offset')}" | ||
| ) | ||
|
|
||
| # Query billing backend |
| user_identity = _extract_user_identity(auth, request) | ||
| agent_id = request.app.state.runtime.agent_identity.agent_id if hasattr(request.app.state, "runtime") else "unknown" | ||
| logger.debug(f"Credit check for user_id={auth.user_id} on agent {agent_id}") | ||
| logger.info("[BILLING_API] agent_id=%s, user_identity=%s", agent_id, user_identity) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix this, we should prevent logging of the entire user_identity object, which contains potentially sensitive fields. Instead, only log non-sensitive, high-level diagnostic information (such as agent ID, and maybe only some flags or anonymized/boolean status information from user_identity if really needed). We should not include fields like external_id, customer_email, or wa_id (the original user ID), as these can all be used to identify a user. The logger call should be changed to only log allowed, non-sensitive information.
We will replace:
logger.info("[BILLING_API] agent_id=%s, user_identity=%s", agent_id, user_identity)with something like:
logger.info(
"[BILLING_API] agent_id=%s, has_oauth_provider=%s, has_external_id=%s, user_role=%s, marketing_opt_in=%s",
agent_id,
user_identity["oauth_provider"] is not None,
user_identity["external_id"] is not None,
user_identity["user_role"],
user_identity["marketing_opt_in"],
)That way, sensitive fields are not logged, but useful diagnostic information is retained. No new imports or dependencies are required; only this single log statement needs updating.
| @@ -327,7 +327,14 @@ | ||
| logger.info("[BILLING_API] get_credits called for user_id=%s", auth.user_id) | ||
| user_identity = _extract_user_identity(auth, request) | ||
| agent_id = request.app.state.runtime.agent_identity.agent_id if hasattr(request.app.state, "runtime") else "unknown" | ||
| logger.info("[BILLING_API] agent_id=%s, user_identity=%s", agent_id, user_identity) | ||
| logger.info( | ||
| "[BILLING_API] agent_id=%s, has_oauth_provider=%s, has_external_id=%s, user_role=%s, marketing_opt_in=%s", | ||
| agent_id, | ||
| user_identity["oauth_provider"] is not None, | ||
| user_identity["external_id"] is not None, | ||
| user_identity["user_role"], | ||
| user_identity["marketing_opt_in"], | ||
| ) | ||
|
|
||
| # Check if we have a resource monitor with credit provider | ||
| if not hasattr(request.app.state, "resource_monitor"): |
| return None | ||
|
|
||
|
|
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
Sensitive user data, such as email addresses and possibly user IDs, must not be logged in cleartext. The best fix is to remove these values from the log message or to redact/mask them. If it is helpful to retain record linkage for debugging, use anonymized versions (e.g., the hash of the email/user_id) or redact most of the value (e.g., only the domain of the email or a partial user ID). In this case, the simplest and safest fix is to remove both {user_email} and possibly {oauth_user.user_id} from the log message. Alternatively, mask part of the email (e.g., show: "e***@domain.com"**) or the user ID (e.g., show only the last 4 characters), depending on requirements.
Implement the fix in file ciris_engine/logic/adapters/api/routes/auth.py, on the lines containing the logging statement (~lines 964–968).
- Remove
{user_email}from the log message and argument list. - Optionally, redact/mask or remove
{oauth_user.user_id}; for the most privacy, remove it. - Retain only non-sensitive data in the log message (e.g., has_credit, marketing_opt_in, role, provider).
No new imports or methods are required if just omitting fields.
If masking is required, add a small utility function for masking emails/user IDs.
| @@ -962,8 +962,8 @@ | ||
| result = await resource_monitor.check_credit(account, context) | ||
|
|
||
| logger.info( | ||
| f"Billing credit check for {oauth_user.user_id}: has_credit={result.has_credit}, " | ||
| f"email={user_email}, marketing_opt_in={marketing_opt_in}, role={oauth_user.role.value}, " | ||
| f"Billing credit check: has_credit={result.has_credit}, " | ||
| f"marketing_opt_in={marketing_opt_in}, role={oauth_user.role.value}, " | ||
| f"provider={resource_monitor.credit_provider.__class__.__name__}" | ||
| ) | ||
|
|
Check warning
Code scanning / CodeQL
URL redirection from remote source Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 15 days ago
The best fix is to ensure redirect targets are always either:
- a trusted configured frontend URL, or
- a safe local relative path whose dynamic parts are sanitized to a strict allowlist.
For this file, the most direct non-breaking fix is:
- In
_build_redirect_response, sanitizeproviderbefore using it ingui_callback_url(fallback branch). - Build
gui_callback_urlonly from safe characters (e.g.,[A-Za-z0-9_-]) and fall back to a constant if invalid. - URL-encode dynamic query values (
email, etc.) via standard libraryurlencodeso tainted values cannot alter URL structure. - Keep behavior intact: still redirect to configured frontend when present; still support relative fallback path.
Edits needed in ciris_engine/logic/adapters/api/routes/auth.py:
- Add standard library imports:
reandurlencodefromurllib.parse. - In
_build_redirect_response, sanitizeproviderwithre.fullmatch(...)before interpolation in fallback path. - Use the sanitized provider in
gui_callback_url.
| @@ -12,10 +12,12 @@ | ||
|
|
||
| import logging | ||
| import os | ||
| import re | ||
| import secrets | ||
| from datetime import datetime, timedelta, timezone | ||
| from pathlib import Path | ||
| from typing import Any, Dict, List, Optional, Set | ||
| from urllib.parse import urlencode | ||
|
|
||
| from fastapi import APIRouter, Depends, HTTPException, Request, status | ||
| from fastapi.responses import RedirectResponse | ||
| @@ -893,7 +891,8 @@ | ||
| logger.info(f"Redirecting OAuth user to configured frontend: {OAUTH_FRONTEND_URL}{OAUTH_FRONTEND_PATH}") | ||
| else: | ||
| # Backward compatibility: relative path | ||
| gui_callback_url = f"/oauth/{AGENT_ID}/{provider}/callback" | ||
| safe_provider = provider if re.fullmatch(r"[A-Za-z0-9_-]+", provider) else "oauth" | ||
| gui_callback_url = f"/oauth/{AGENT_ID}/{safe_provider}/callback" | ||
| redirect_url = f"{gui_callback_url}?{query_string}" | ||
| # Do NOT log the full redirect_url with sensitive credentials (access_token, api_key) | ||
| logger.warning( |
Summary
IncidentCaptureHandler._save_incident_to_graph()was never called - incidents went to file only, never to graphMemoryBus.memorize_log()which createsLOG_ENTRYcorrelations per CORRELATIONS_TSDB designChanges
incident_capture_handler.py_write_to_graph()usingmemorize_log()test_incident_capture_handler.pyAnti-Spam Patterns Used
Reused existing patterns from
ciris_engine/logic/telemetry/security.py:SecurityFilter._check_rate_limit)asyncio.create_task()withadd_done_callbackcleanupTest plan
_write_to_graph()callsmemorize_log()correctlyset_memory_bus()andset_graph_audit_service()🤖 Generated with Claude Code