Conversation
- Root: pnpm workspaces, Turborepo, tsconfig.base, .gitignore, .env.example - packages/contracts: billing, access, usage, ai, plugin, sync, web3 contracts (Zod-validated) - packages/services: Stripe, Firebase, AI router (OpenAI/Claude/Gemini), plugin engine - packages/middleware: JWT auth, billing tier, RBAC, usage/rate-limit middleware - packages/ui: GlassCard, NeonButton, AICommandBar, PromptCard, BillingDashboard, PluginTile (NEON GLASS OS theme) - packages/config: Zod-validated env config - apps/web: Next.js 14 App Router, API routes (billing, ai, plugins, usage, stripe webhook), dashboard + optimizer pages - apps/desktop: Electron 28 main process + preload, electron-builder config - apps/mobile: React Native Expo 50, bottom tab nav, optimizer + dashboard screens - Docker: Dockerfile.web, docker-compose.yml - CI/CD: GitHub Actions ci.yml (lint + type-check + build), deploy-web.yml (Vercel) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
- Add explicit permissions: read to all GitHub Actions jobs - Add /api/health route to fix docker-compose health check - Implement Redis singleton to avoid repeated connection creation - Use lazy initialization for Stripe client with fail-fast env validation - Validate STRIPE_WEBHOOK_SECRET before use in webhook handler Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Algodons/PromptOS/sessions/7e161a33-b761-4114-8717-a20aaf227578 Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
…ld scripts Agent-Logs-Url: https://github.com/Algodons/PromptOS/sessions/7e161a33-b761-4114-8717-a20aaf227578 Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
- tailwind: move custom colors to theme.extend.colors to preserve Tailwind defaults (text-red-*, text-yellow-*, etc.)
- usage/summary: fix Firestore path to use flat 'usage/{userId}_{period}' (odd segments)
- stripe: use invoice.subscription_details.metadata.userId instead of customer_email in payment_failed handler
- auth: fail fast with clear error when JWT_SECRET is not set
- ai router: honor targetModel in optimizePrompt() instead of always using GPT_4O_MINI
- AICommandBar: sync internal model state via useEffect when selectedModel prop changes
- plugin engine: add registerPluginModule() API; getOrCreateSandbox throws clear error when module not loaded instead of silent no-op
- billing/checkout: remove successUrl/cancelUrl from client schema; URLs always server-generated
- ai/optimize route: switch to withOptionalAuth to allow unauthenticated access; pass targetModel through
- mobile OptimizerScreen: attach Bearer token from AsyncStorage when available
- security: upgrade next 14.2.4 -> 14.2.35, electron ^28.3.3 -> ^39.8.1
- fix: update @promptos/middleware next peer dep to ^14.2.35 to resolve NextRequest type mismatch"
Agent-Logs-Url: https://github.com/Algodons/PromptOS/sessions/95f215e6-a99f-4e13-80e8-6a4f3a9314dc
Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
…check Agent-Logs-Url: https://github.com/Algodons/PromptOS/sessions/3b978979-0cf4-4c61-b7a5-09b5dc004a72 Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Algodons/PromptOS/sessions/3b978979-0cf4-4c61-b7a5-09b5dc004a72 Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to resolve CI TypeScript failures in @promptos/mobile (Expo/React Native) by adjusting the mobile TypeScript config and dependencies, and it also brings in a large set of monorepo scaffolding and shared packages (contracts/services/middleware/ui/config) plus web/desktop app foundations and CI/deploy tooling.
Changes:
- Fix
@promptos/mobiletype-check by settingtsconfigmodule target, adding missing dependencies, and switching runtime config access toexpo-constants. - Introduce shared workspace packages (
@promptos/contracts,@promptos/services,@promptos/middleware,@promptos/ui,@promptos/config) and wire them into the web app. - Add/standardize Turborepo + pnpm workspace setup, CI workflows, and Docker/Vercel deployment configuration.
Reviewed changes
Copilot reviewed 79 out of 82 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| turbo.json | Adds Turborepo pipeline configuration for build/lint/type-check/test/clean. |
| tsconfig.base.json | Introduces a strict base TypeScript configuration for workspace packages/apps. |
| pnpm-workspace.yaml | Defines workspace package globs for pnpm. |
| package.json | Root workspace scripts (turbo) and devDependencies. |
| Dockerfile.web | Container build for the Next.js web app using pnpm + turbo. |
| docker-compose.yml | Compose setup for web + redis. |
| .gitignore | Standard ignores for node/turbo/next/expo/electron artifacts and env files. |
| .env.example | Root env template covering auth/stripe/ai/firebase/walletconnect/ratelimit. |
| .github/workflows/ci.yml | CI workflow running pnpm turbo run type-check and lint, plus package builds. |
| .github/workflows/deploy-web.yml | Vercel deployment workflow for main. |
| apps/web/package.json | Web app dependencies/scripts (Next.js 14) and workspace package usage. |
| apps/web/tsconfig.json | Web TS config aligned to Next + bundler resolution and path aliases. |
| apps/web/next.config.js | Next config enabling transpilePackages and server external packages. |
| apps/web/next-env.d.ts | Next-generated TS ambient references. |
| apps/web/postcss.config.js | PostCSS config enabling Tailwind + autoprefixer. |
| apps/web/tailwind.config.ts | Tailwind config extending the shared UI config and setting content globs. |
| apps/web/.env.example | Web-scoped env template referencing the root env example. |
| apps/web/src/app/layout.tsx | App Router root layout and global font/style setup. |
| apps/web/src/app/globals.css | Global Tailwind layers and shared “glass/neon” component styles. |
| apps/web/src/app/page.tsx | Marketing/home landing page. |
| apps/web/src/app/dashboard/page.tsx | Dashboard placeholder UI. |
| apps/web/src/app/optimizer/page.tsx | Client-side optimizer UI calling /api/ai/optimize. |
| apps/web/src/app/api/health/route.ts | Health endpoint with timestamp/version response. |
| apps/web/src/app/api/ai/optimize/route.ts | Optional-auth optimize endpoint delegating to aiRouterService.optimizePrompt. |
| apps/web/src/app/api/ai/complete/route.ts | Auth + rate-limited AI completion endpoint validating request schema. |
| apps/web/src/app/api/usage/summary/route.ts | Usage summary endpoint reading subscription tier and usage docs from Firestore. |
| apps/web/src/app/api/billing/checkout/route.ts | Checkout session creation using Stripe service and server-generated URLs. |
| apps/web/src/app/api/billing/portal/route.ts | Billing portal session creation for existing Stripe customers. |
| apps/web/src/app/api/billing/cancel/route.ts | Subscription cancellation endpoint. |
| apps/web/src/app/api/webhooks/stripe/route.ts | Stripe webhook handler mapping Stripe events to Firestore + custom claims updates. |
| apps/web/src/app/api/plugins/install/route.ts | Plugin install endpoint validating manifest and calling pluginEngine.installPlugin. |
| apps/web/src/app/api/plugins/uninstall/route.ts | Plugin uninstall endpoint calling pluginEngine.uninstallPlugin. |
| apps/mobile/package.json | Adds missing mobile deps (AsyncStorage, expo-constants) and type-check script. |
| apps/mobile/tsconfig.json | Sets module: esnext to support dynamic imports / ESM semantics in TS. |
| apps/mobile/app.json | Expo app config (name/slug/platform IDs/plugins/extra). |
| apps/mobile/src/screens/DashboardScreen.tsx | Mobile dashboard placeholder UI. |
| apps/mobile/src/screens/OptimizerScreen.tsx | Mobile optimizer screen using AsyncStorage token + expo-constants config for API URL. |
| apps/mobile/src/screens/PluginsScreen.tsx | Mobile plugins placeholder UI. |
| apps/mobile/src/screens/SettingsScreen.tsx | Mobile settings placeholder UI. |
| apps/mobile/src/navigation/TabNavigator.tsx | Mobile bottom tab navigation wiring the screens. |
| apps/desktop/package.json | Electron desktop app setup (electron-builder, updater, dev scripts). |
| apps/desktop/tsconfig.json | Desktop TS config targeting CommonJS/node resolution for Electron main/preload. |
| apps/desktop/src/main.ts | Electron main process creating window, menu, and auto-update wiring. |
| apps/desktop/src/preload.ts | Electron preload exposing limited IPC APIs via contextBridge. |
| packages/contracts/package.json | Contracts package build/type-check scripts and zod dependency. |
| packages/contracts/tsconfig.json | Contracts TS config for dist output using bundler resolution. |
| packages/contracts/src/index.ts | Barrel export for all contract modules. |
| packages/contracts/src/billing.contract.ts | Subscription tiers/limits/feature flags and Stripe checkout schema. |
| packages/contracts/src/access.contract.ts | Roles/permissions/JWT payload schema and helpers. |
| packages/contracts/src/ai.contract.ts | AI provider/model contracts and request/response schemas. |
| packages/contracts/src/plugin.contract.ts | Plugin manifest/install/execution contracts and schemas. |
| packages/contracts/src/usage.contract.ts | Usage metrics contracts and token-cost calculator. |
| packages/contracts/src/sync.contract.ts | Sync contracts for offline/queue/conflict resolution models. |
| packages/contracts/src/web3.contract.ts | Web3 auth/session/NFT gating request contracts. |
| packages/services/package.json | Services package deps (Stripe, Firebase, AI SDKs) and build/type-check scripts. |
| packages/services/tsconfig.json | Services TS config for dist output using bundler resolution. |
| packages/services/src/index.ts | Barrel export for services modules. |
| packages/services/src/stripe.service.ts | Stripe client + checkout/portal/webhook handling helpers. |
| packages/services/src/firebase.service.ts | Firebase Admin initialization and Firestore/RTDB/Auth helper methods. |
| packages/services/src/ai.router.service.ts | AI router service for OpenAI/Anthropic/Gemini + optimization routine. |
| packages/services/src/plugin.engine.ts | In-memory plugin registry/installation and hook execution engine. |
| packages/middleware/package.json | Next middleware utilities package deps and scripts. |
| packages/middleware/tsconfig.json | Middleware TS config for dist output using bundler resolution. |
| packages/middleware/src/index.ts | Barrel export for middleware functions. |
| packages/middleware/src/auth.middleware.ts | JWT sign/verify and auth/optional-auth request wrappers. |
| packages/middleware/src/billing.middleware.ts | Tier/feature gating wrappers and tier limit accessor. |
| packages/middleware/src/rbac.middleware.ts | Permission-based request wrappers. |
| packages/middleware/src/usage.middleware.ts | Upstash rate limiting and usage tracking helpers. |
| packages/ui/package.json | UI component package with tsup build and peer deps for React. |
| packages/ui/tsconfig.json | UI TS config with JSX + DOM libs. |
| packages/ui/tailwind.config.ts | Shared Tailwind theme/config exported for apps to extend. |
| packages/ui/src/index.ts | UI barrel exporting shared components. |
| packages/ui/src/components/GlassCard.tsx | Shared “glass” card component. |
| packages/ui/src/components/NeonButton.tsx | Shared neon-styled button component. |
| packages/ui/src/components/AICommandBar.tsx | Shared AI command bar component with model selector + submit UX. |
| packages/ui/src/components/PromptCard.tsx | Shared prompt card component. |
| packages/ui/src/components/BillingDashboard.tsx | Shared billing/usage UI component. |
| packages/ui/src/components/PluginTile.tsx | Shared plugin tile UI component. |
| packages/config/package.json | Config/env package with zod schema parsing. |
| packages/config/tsconfig.json | Config package TS config with node types. |
| packages/config/src/index.ts | Environment variable schema validation and public env accessor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const result = await Promise.race([ | ||
| sandbox.execute(context), | ||
| new Promise<never>((_, reject) => | ||
| setTimeout(() => reject(new Error("Plugin execution timeout")), context.timeoutMs) | ||
| ), | ||
| ]); |
| if (manifest.hooks.onInstall) { | ||
| await this.executeHook(installation, "onInstall", {}); | ||
| } |
| const messages: Anthropic.Messages.MessageParam[] = request.messages.map((m) => ({ | ||
| role: m.role === "assistant" ? "assistant" as const : "user" as const, | ||
| content: m.content, | ||
| })); |
| onSubmit, | ||
| placeholder = "Enter a prompt or command... (⌘K to focus)", | ||
| models = ["gpt-4o-mini", "gpt-4o", "claude-3-5-sonnet", "gemini-1.5-flash"], | ||
| selectedModel, |
| // Anonymous users are allowed with a lower quota; authenticated users get tier limits | ||
| const userId = user?.sub ?? "anonymous"; | ||
|
|
||
| // Enforce prompt limit for free/anonymous tier | ||
| if (!user) { | ||
| const ip = req.headers.get("x-forwarded-for") ?? "unknown"; | ||
| const tierLimit = TierLimits[SubscriptionTier.FREE].monthlyPrompts; | ||
| // IP-based limiting is handled by upstream infrastructure; log for monitoring | ||
| console.info(`[optimize] anonymous request from ${ip}, userId=anonymous, limit=${tierLimit}`); | ||
| } |
| const API_URL = | ||
| (Constants.expoConfig?.extra as { EXPO_PUBLIC_API_URL?: string }) | ||
| ?.EXPO_PUBLIC_API_URL ?? "http://localhost:3000"; | ||
|
|
Agent-Logs-Url: https://github.com/Algodons/PromptOS/sessions/67a8f476-f151-4ba1-afa3-6fff2f82029e Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
Fixed in commit |
apps/mobile/tsconfig.jsonwith"module": "esnext"to fix TS1323@react-native-async-storage/async-storagetoapps/mobile/package.jsonto fix TS2307expo-constantstoapps/mobile/package.jsondependenciesapps/mobile/src/screens/OptimizerScreen.tsxto useexpo-constantsinstead ofprocess.env(fix TS2580) and static import instead of dynamic importexpo-constantstype assertionpnpm-lock.yamlusing pnpm v8.15.9 (matching CI'spnpm/action-setup@v3 version: 8) — fixesERR_PNPM_LOCKFILE_CONFIG_MISMATCHthat blockedpnpm install --frozen-lockfilepnpm install --frozen-lockfilesucceeds (CI simulation)pnpm turbo run type-checkpasses (13/13 tasks successful)Original prompt
Fix CI failing
@promptos/mobile#type-checkin PR #1.CI (
.github/workflows/ci.yml) runspnpm turbo run type-checkand currently fails with TypeScript errors inapps/mobile/src/screens/OptimizerScreen.tsx:process(use ofprocess.env["EXPO_PUBLIC_API_URL"])tsconfigcompilerOptions.module@react-native-async-storage/async-storageMake changes that:
apps/mobile/tsconfig.jsonappropriately.@react-native-async-storage/async-storagetoapps/mobile/package.json(and update lockfile as needed).processin the mobile app type-check by switching to an Expo-compatible config approach (preferexpo-constants), or otherwise properly type it without polluting RN with Node globals.Keep changes minimal and aligned with Expo/React Native conventions. Ensure
pnpm turbo run type-checkpasses.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for failing job 74552942938. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The failing job 74552942938 is failing in
@promptos/mobile→pnpm run type-check(tsc --noEmit) with three TypeScript errors inapps/mobile/src/screens/OptimizerScreen.tsxat commita01d02257460ec96f8b56e09679983c833da2da3:TS2580: Cannot find name 'process'(line 21)TS1323: Dynamic imports are only supported when the '--module' flag is set to ...(line 36)TS2307: Cannot find module '@react-native-async-storage/async-storage' or its corresponding type declarations.(line 36)Below are focused fixes that address each error.
1) Fix
process.envtyping in Expo (TS2580)Problem line:
OptimizerScreen.tsxuses:In an Expo/React Native TS project,
processis not typed unless Node types are present (and you generally don’t want full Node globals in RN).Recommended fix (Expo-native): use
expo-constantsUse
Constants.expoConfig?.extraorConstants.expoConfig?.hostUripatterns. Since you’re using anEXPO_PUBLIC_env var, a common pattern is to read it viaConstants.expoConfig?.extra(populated fromapp.config.js/tsorapp.json).Code change (apps/mobile/src/screens/OptimizerScreen.tsx):
If you do want to keep
process.envin this file, then add Node types:Add dev dependency (apps/mobile/package.json):
…but for Expo/RN,
expo-constants(or a typed env approach) is typically cleaner than enabling Node globals.2) Fix dynamic
import()module setting (TS1323)You have a dynamic import here:
Your
apps/mobile/tsconfig.jsonextendsexpo/tsconfig.baseand does not explicitly setcompilerOptions.module. The current module target is not compatible with dynamic import during type-check.Fix: set
moduleto a supported value (ESNext is typical for Expo)Update
apps/mobile/tsconfig.json:{ "extends": "expo/tsconfig.base", "compilerOptions": { "strict": true, "module": "esnext", "paths": { "@/*": ["./src/*"] } }, "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.d.ts", "expo-env.d.ts"], "exclude": ["node_modules"] }This directly resolves the
TS1323error.(Alternative: remove the dynamic import and use a normal static import; see next section.)
3) Install missing dependency (TS2307)
TypeScript can’t resolve
@react-native-async-storage/async-storagebecause it is not listed inapps/mobile/package.jsondependencies. The file imports it dynamically, but TypeScript still needs to resolve the module.Fix: add AsyncStorage to mobile dependencies
Add to
apps/mobile/package.jsondependencies:Then run install (repo root):
pnpm installOptional simplification: switch to static import
Once the dependency is present, you can avoid the dynamic import entirely (and this also makes TS con...
This pull request was created from Copilot chat.