Skip to content

Add organization billing model and members/billing console flows#1

Closed
RhysSullivan wants to merge 34 commits into
mainfrom
feat/org-workspace-billing-members
Closed

Add organization billing model and members/billing console flows#1
RhysSullivan wants to merge 34 commits into
mainfrom
feat/org-workspace-billing-members

Conversation

@RhysSullivan
Copy link
Copy Markdown
Owner

Summary

  • add an org-first Convex data model and APIs for organizations, memberships, invites, workspace ownership, and seat-based Stripe billing sync
  • integrate @convex-dev/stripe into Convex config and wire webhook registration, plus billing actions/queries for checkout, portal, and seat sync retries
  • add members and billing routes/views in the web app and update session/navigation flows to support org-aware workspace selection and invite/billing provider state
  • move task/tool frontend calls to Convex executor functions (executor / executorNode) and remove the old web executor-client wrapper

Validation

  • ran bun run convex:codegen in executor
  • ran bun test in executor

- Updated ToolSourceRecord and related interfaces to include "graphql" as a valid type.
- Modified database mapping and service logic to accommodate GraphQL tool sources.
- Enhanced API and UI components to support GraphQL endpoint configuration and validation.
- Implemented GraphQL-specific logic for tool approval decisions and introspection handling.
Replace the SQLite storage layer with Convex functions and switch dev scripts/docs to run convex locally so the migration stays off cloud deployments.
Move execution to a dedicated worker and switch the web UI to Convex reactive queries so task, approval, and tool state update without polling or SSE.
Track workspace tool-source updates in Convex and have the worker refresh cached tool inventory so the web UI stays live without calling /api/tools for warmup.
- Added `convex-test` as a development dependency in `package.json` and `bun.lock`.
- Introduced access policy management in `service.test.ts`, including methods for listing and upserting access policies.
- Enhanced runtime execution handling in `runtime-core.ts` and `vercel-sandbox-runtime.ts` to support new policy checks and improved error handling for script execution timeouts.
- Updated tests in `runtime-core.test.ts` to improve checks against global constructor and eval escapes, ensuring that sensitive host globals are not exposed.
- Modified `runCodeWithAdapter` in `runtime-core.ts` and `vercel-sandbox-runtime.ts` to utilize a sandboxed context with stricter code generation settings, enhancing security during code execution.
- Added new tests to verify that prototype pollution does not leak to the host environment, further strengthening the sandbox's isolation features.
Add a /mcp endpoint with a run_code tool so external MCP clients can trigger executor runs, and extend MCP source config/UI with transport and query parameter support for anon scoping.
Migrate executor server from raw Bun.serve() to Elysia with typed route
schemas, enabling Eden Treaty to infer types directly from the server
definition. This eliminates the need for separate contracts and client
packages — the server is the contract.

- Rewrite executor server index.ts using Elysia typed routes
- Replace assistant adapter with 8-line Eden Treaty client
- Delete executor/packages/contracts and executor/packages/client
- Delete dead web app api.ts (migrated to Convex)
- Remove tsconfig path aliases for deleted packages
Introduces the assistant side of the system:
- @assistant/core: agent loop (Claude via pi-ai) with run_code tool calling
- @assistant/server: Elysia API with SSE task streaming and Eden Treaty client
- @assistant/bot: Discord bot (Reacord) with /ask command, live approval buttons via Convex reactivity
- Executor sync endpoint (POST /api/tasks/run) for blocking code execution
- dev.ts multi-service orchestrator (bun dev starts everything)
- Root workspace config for cross-package resolution
Store agent tasks in Convex (agentTasks table) instead of in-memory state.
Bot uses useQuery from convex/react for reactive updates — no more HTTP
polling or SSE. Deletes state.ts and simplifies server routes significantly.
Agent is now a pure MCP client — connects to executor's /mcp endpoint,
gets tools via tools/list (run_code description includes sandbox tool
inventory), executes code via tools/call. Removes hardcoded run_code
tool definition, POST /api/tasks/run endpoint, and Eden Treaty adapter
dependency from the agent path. Model accepts tools dynamically.
Delete model.ts — agent owns the LLM call directly. No more generate
function passing, no more createModel factory. Agent auto-resolves API
key from env/credentials file. Server is just config passthrough.
waitForTerminalTask now uses service.subscribe() instead of polling
getTask every 300ms. Resolves instantly when the TaskEventHub fires
a terminal event.
- Added "esbuild" as a development dependency in package.json files across executor and server apps.
- Updated esbuild package versions in bun.lock to 0.27.3 for various platforms, ensuring compatibility and access to the latest features.
Use openapi-typescript for high-fidelity JSON Schema → TypeScript conversion
in tool type signatures. Typecheck code against tool declarations using the
TS compiler API before creating tasks, so type errors are caught early and
returned to the agent without executing. Includes 24 tests for the typechecker.
Remove nested workspace declarations and lockfiles from executor/ and
assistant/ — the root package.json already defines all workspace paths.
Fixes Turbopack CSS resolution failures (tailwindcss, shadcn) caused by
enhanced-resolve walking up to the wrong node_modules boundary.

Also adds executor web UI (port 3002) to the dev runner and restores
the missing CONVEX_DEPLOYMENT in executor/.env.local.
…tion

- Added entries to .gitignore for Convex local backend state files and generated push environment file.
- Modified dev.ts to include a new service for Convex function watcher and improved backend management functions, including starting the backend and pushing functions with appropriate configurations.
- Refactored service spawning and output handling for better clarity and maintainability.
…er package

- Move @openassistant/reacord to assistant/packages/reacord/ (only actively used legacy package)
- Delete entire assistant/legacy/openassistant/ directory (~515MB of superseded code)
- Delete unused assistant/packages/agent-executor-adapter/ (9-line wrapper never imported)
- Update workspace entries in root and assistant package.json
- Create executor/packages/contracts/ with all shared type definitions
- Server and web now import from @executor/contracts instead of maintaining copies
- Fixes type drift (e.g. TaskEventRecord.eventName was narrower in web)
- Remove empty package stubs (confect/, convex/, database/)
- Pin convex versions consistently, remove unused deps (@elysiajs/eden, esbuild)
…llbacks

- Delete HttpExecutionAdapter (entire file, never imported)
- Remove unused isRequired() from tool-sources.ts
- Remove unused ApprovalStatusBadge from status-badge.tsx
- Remove no-op refresh callback from use-workspace-tools hook and callers
- Remove vestigial exitCode/stderr fields from TaskCodeResultEvent
- Fix missing Button import in approvals-view.tsx
- Remove unused @elysiajs/eden and elysia devDeps from @assistant/core
- Extract asRecord/describeError/asPayload to executor server utils.ts
- Extract formatTime/formatTimeAgo to executor web lib/format.ts
- Add sync comments to duplicated matchesToolPath/policySpecificity
- Create typed executor client (assistant/packages/server/src/executor-client.ts)
- Replace raw fetch() in assistant server with typed Eden client
- Replace untyped treaty() in bot with typed createExecutorClient
- Replace inline executor type annotations in bot commands
- Replace all any types in convex/database.ts with proper Doc<>/QueryCtx types
- Add explanatory comment for as-never casts in database wrapper
…idation

- Extract MCP handler to shared function instead of copy-pasting for 3 HTTP methods
- Remove redundant manual workspaceId/body validation (Elysia schema already validates)
- Simplify getBaseToolCount() to use baseTools.size
- Fix .gitignore wildcard patterns (_.log -> *.log)
- Increase editor height from 240px to 400px, remove overflow-hidden
  that clipped autocomplete/hover widgets, add fixedOverflowWidgets
- Use versioned extra lib filenames and setEagerModelSync to fix
  IntelliSense completions not updating when tools load asynchronously
- Trigger server-side tool refresh (GET /api/tools) after adding a
  tool source so workspace inventory syncs immediately
- Add turbopack: {} to next.config.ts to silence Next.js 16 warning
- Create sandbox-fragments.ts with named string-builder functions for shared logic
- Vercel sandbox runtime now composes from fragments instead of inline ~200 lines
- APPROVAL_DENIED_PREFIX and TASK_TIMEOUT_MARKER now flow from execution-constants.ts
- Add cross-reference comments between runtime-core.ts and sandbox-fragments.ts
…t Convex mutation

Tasks created from the web UI now go through POST /api/tasks on the executor
server, which runs typechecking, publishes events, and handles auto-execution
instead of bypassing the service layer via direct Convex mutation.
…web UI

- cli.test.ts: bootstrap, health, approvals, tasks all use Eden now
- tasks-view.tsx: task creation uses typed executor.api.tasks.post()
- Add executor-client.ts to web app with Eden Treaty<App> client
- Add @elysiajs/eden to web deps and @executor/server/* tsconfig path
…e tool sync

- Rewrite useWorkspaceTools hook to use @tanstack/react-query + Eden
- Add QueryClientProvider to app layout
- Remove syncWorkspaceTools/listWorkspaceToolsForContext from database layer
- Remove workspace tool inventory sync from service and worker
- Tools are now fetched directly from the API, not materialized to Convex
@RhysSullivan
Copy link
Copy Markdown
Owner Author

Superseded by #2 after main was pushed and PR base was stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant