compassmock/docs/auth/PEOPLE-SYSTEM-STATUS.md
Nicholai 8b34becbeb
feat(agent): AI agent harness with memory, GitHub, audio & feedback (#37)
* feat(agent): replace ElizaOS with AI SDK v6 harness

Replace custom ElizaOS sidecar proxy with Vercel AI SDK v6 +
OpenRouter provider for a proper agentic harness with multi-step
tool loops, streaming, and D1 conversation persistence.

- Add AI SDK agent library (provider, tools, system prompt, catalog)
- Rewrite API route to use streamText with 10-step tool loop
- Add server actions for conversation save/load/delete
- Migrate chat-panel and dashboard-chat to useChat hook
- Add action handler dispatch for navigate/toast/render tools
- Use qwen/qwen3-coder-next via OpenRouter (fallbacks disabled)
- Delete src/lib/eliza/ (replaced entirely)
- Exclude references/ from tsconfig build

* fix(chat): improve dashboard chat scroll and text size

- Rewrite auto-scroll: pin user message 75% out of
  frame after send, then follow bottom during streaming
- Use useEffect for scroll timing (DOM guaranteed ready)
  instead of rAF which fired before React commit
- Add user scroll detection to disengage auto-scroll
- Bump assistant text from 13px back to 14px (text-sm)
- Tighten prose spacing for headings and lists

* chore: installing new components

* refactor(chat): unify into one component, two presentations

Extract duplicated chat logic into shared ChatProvider context
and useCompassChat hook. Single ChatView component renders as
full-page hero on /dashboard or sidebar panel elsewhere. Chat
state persists across navigation.

New: chat-provider, chat-view, chat-panel-shell, use-compass-chat
Delete: agent-provider, chat-panel, dashboard-chat, 8 deprecated UI files
Fix: AI component import paths (~/  -> @/), shadcn component updates

* fix(lint): resolve eslint errors in AI components

- escape unescaped entities in demo JSX (actions, artifact,
  branch, reasoning, schema-display, task)
- add eslint-disable for @ts-nocheck in vendor components
  (file-tree, terminal, persona)
- remove unused imports in chat-view (ArrowUp, Square,
  useChatPanel)

* feat(agent): rename AI to Slab, add proactive help

rename assistant from Compass to Slab and add first
interaction guidance so it proactively offers
context-aware help based on the user's current page.

* fix(build): use HTML entity for strict string children

ReasoningContent expects children: string, so JSX
expression {"'"} splits into string[] causing type error.
Use ' HTML entity instead.

* feat(agent): add memory, github, audio, feedback

- persistent memory system (remember/recall across sessions)
- github integration (commits, PRs, issues, contributors)
- audio transcription via Whisper API
- UX feedback interview flow with auto-issue creation
- memories management table in settings
- audio waveform visualization component
- new schema tables: slab_memories, feedback_interviews
- enhanced system prompt with proactive tool usage

* feat(agent): unify chat into single morphing instance

Replaces two separate ChatView instances (page + panel) with
one layout-level component that transitions between full-page
and sidebar modes. Navigation now actually works via proper
AI SDK v6 part structure detection, with view transitions for
smooth crossfades, route validation to prevent 404s, and
auto-opening the panel when leaving dashboard.

Also fixes dark mode contrast, user bubble visibility, tool
display names, input focus ring, and system prompt accuracy.

* refactor(agent): rewrite waveform as time-series viz

Replace real-time frequency equalizer with amplitude
history that fills left-to-right as user speaks.
Bars auto-calculated from container width, with
non-linear boost and scroll when full.

* (feat): implemented architecture for plugins and skills, laying a foundation for future implementations of packages separate from the core application

* feat(agent): add skills.sh integration for slab

Skills client fetches SKILL.md from GitHub, parses
YAML frontmatter, and stores content in plugin DB.
Registry injects skill content into system prompt.
Agent tools and settings UI for skill management.

* feat(agent): add interactive UI action bridge

Wire agent-generated UIs to real server actions via
an action bridge API route. Forms submit, checkboxes
persist, and DataTable rows support CRUD operations.

- action-registry.ts: maps 19 dotted action names to
  server actions with zod validation + permissions
- /api/agent/action: POST route with auth, permission
  checks, schema validation, and action execution
- schema-agent.ts: agent_items table for user-scoped
  todos, notes, and checklists
- agent-items.ts: CRUD + toggle actions for agent items
- form-context.ts: FormIdProvider for input namespacing
- catalog.ts: Form component, value/onChangeAction props,
  DataTable rowActions, mutate/confirmDelete actions
- registry.tsx: useDataBinding on all form inputs, Form
  component, DataTable row action buttons, inline
  Checkbox/Switch mutations
- actions.ts: mutate + confirmDelete handlers that call
  the action bridge, formSubmit now collects + submits
- system-prompt.ts: interactive UI patterns section
- render/route.ts: interactive pattern custom rules

* docs: reorganize into topic subdirectories

Move docs into auth/, chat/, openclaw-principles/,
and ui/ subdirectories. Add openclaw architecture
and system prompt documentation.

* feat(agent): add commit diff support to github tools

Add fetchCommitDiff to github client with raw diff
fallback for missing patches. Wire commit_diff query
type into agent github tools.

* fix(ci): guard wrangler proxy init for dev only

initOpenNextCloudflareForDev() was running unconditionally
in next.config.ts, causing CI build and lint to fail with
"You must be logged in to use wrangler dev in remote mode".
Only init the proxy when NODE_ENV is development.

---------

Co-authored-by: Nicholai <nicholaivogelfilms@gmail.com>
2026-02-06 17:04:04 -07:00

6.9 KiB
Executable File

people management system - implementation status

completed work

phase 1: database and auth foundation

database schema (src/db/schema.ts)

  • users table (workos user sync)
  • organizations table (internal vs client orgs)
  • organization_members (user-org mapping)
  • teams and team_members
  • groups and group_members
  • project_members (project-level access)
  • migration generated and applied: drizzle/0006_brainy_vulcan.sql

auth integration

  • workos authkit installed: @workos-inc/authkit-nextjs
  • middleware with dev mode fallback: src/middleware.ts
    • bypasses auth when workos not configured
    • allows dev without real credentials
  • auth utilities: src/lib/auth.ts
    • getCurrentUser() - returns mock user in dev mode
    • ensureUserExists() - syncs workos users to db
    • handleSignOut() - logout functionality
  • permissions system: src/lib/permissions.ts
    • 4 roles: admin, office, field, client
    • resource-based permissions (project, schedule, budget, etc)
    • can(), requirePermission(), getPermissions() helpers
  • callback handler: src/app/callback/route.ts

environment setup

  • .dev.vars updated with workos placeholders
  • wrangler.jsonc configured with WORKOS_REDIRECT_URI

phase 2: server actions

user management (src/app/actions/users.ts)

  • getUsers() - fetch all users with relations
  • updateUserRole() - change user role
  • deactivateUser() - soft delete
  • assignUserToProject() - project assignment
  • assignUserToTeam() - team assignment
  • assignUserToGroup() - group assignment
  • inviteUser() - create invited user

organizations (src/app/actions/organizations.ts)

  • getOrganizations() - fetch all orgs
  • createOrganization() - create new org

teams (src/app/actions/teams.ts)

  • getTeams() - fetch all teams
  • createTeam() - create new team
  • deleteTeam() - remove team

groups (src/app/actions/groups.ts)

  • getGroups() - fetch all groups
  • createGroup() - create new group
  • deleteGroup() - remove group

all actions follow existing project patterns:

  • use getCloudflareContext() for D1 access
  • permission checks with requirePermission()
  • return { success, error? } format
  • revalidatePath() after mutations

phase 3: basic ui

navigation

  • people nav item added to sidebar (src/components/app-sidebar.tsx)

people page (src/app/dashboard/people/page.tsx)

  • client component with useEffect data loading
  • loading state
  • empty state
  • table integration
  • edit and deactivate handlers

people table (src/components/people-table.tsx)

  • tanstack react table integration
  • columns: checkbox, name/email, role, teams, groups, projects, actions
  • search by name/email
  • filter by role dropdown
  • row selection
  • pagination
  • actions dropdown (edit, assign, deactivate)

seed data

  • seed-users.sql with 5 users, 2 orgs, 2 teams, 2 groups
  • applied to local database
  • users include admin, office, field, and client roles

remaining work

phase 4: advanced ui components

user drawer (src/components/people/user-drawer.tsx)

  • full profile editing
  • tabs: profile, access, activity
  • role/team/group assignment
  • avatar upload

invite dialog (src/components/people/invite-user-dialog.tsx)

  • email input with validation
  • user type selection (team/client)
  • organization selection
  • role/group/team assignment
  • integration with inviteUser() action

bulk actions (src/components/people/bulk-actions-bar.tsx)

  • appears when rows selected
  • bulk role assignment
  • bulk team/group assignment
  • bulk deactivate

supporting components

  • role-selector.tsx
  • group-selector.tsx
  • team-selector.tsx
  • permissions-editor.tsx (advanced permissions UI)
  • user-avatar-upload.tsx

phase 5: workos configuration

dashboard setup

  1. create workos account
  2. create organization
  3. get API keys (client_id, api_key)
  4. generate cookie password (32+ chars)

update credentials

  • .dev.vars - local development
  • wrangler secrets - production
    wrangler secret put WORKOS_API_KEY
    wrangler secret put WORKOS_CLIENT_ID
    wrangler secret put WORKOS_COOKIE_PASSWORD
    

test auth flow

  • login/logout
  • user creation on first login
  • session management
  • redirect after auth

phase 6: integration and testing

end-to-end testing

  • invite user flow
  • edit user profile
  • role assignment
  • team/group assignment
  • project access
  • permission enforcement
  • mobile responsive
  • accessibility

cross-browser testing

  • chrome, firefox, safari
  • mobile browsers

phase 7: production deployment

database migration

bun run db:migrate:prod

deploy

bun deploy

post-deployment

  • verify workos callback URL
  • test production auth flow
  • invite real users
  • verify permissions

technical notes

dev mode behavior

when workos env vars contain "placeholder" or are missing:

  • middleware allows all requests through
  • getCurrentUser() returns mock admin user
  • no actual authentication happens
  • allows building/testing UI without workos setup

database patterns

  • all IDs are text (UUIDs)
  • all dates are text (ISO 8601)
  • boolean columns use integer(mode: "boolean")
  • foreign keys with onDelete: "cascade"
  • getCloudflareContext() for D1 access in actions

permission model

  • role-based by default (4 roles)
  • resource + action pattern
  • extensible for granular permissions later
  • enforced in server actions

ui patterns

  • client components use "use client"
  • server actions called from client
  • toast notifications for user feedback
  • optimistic updates where appropriate
  • revalidatePath after mutations

files created/modified

new files

  • src/middleware.ts
  • src/lib/auth.ts
  • src/lib/permissions.ts
  • src/app/callback/route.ts
  • src/app/actions/users.ts
  • src/app/actions/organizations.ts
  • src/app/actions/teams.ts
  • src/app/actions/groups.ts
  • src/app/dashboard/people/page.tsx
  • src/components/people-table.tsx
  • src/components/people/ (directory for future components)
  • drizzle/0006_brainy_vulcan.sql
  • seed-users.sql

modified files

  • src/db/schema.ts (added auth tables and types)
  • src/components/app-sidebar.tsx (added people nav item)
  • .dev.vars (added workos placeholders)
  • wrangler.jsonc (added WORKOS_REDIRECT_URI)

next steps

  1. test current implementation

    bun dev
    # visit http://localhost:3000/dashboard/people
    # verify table loads with seed data
    
  2. build user drawer - most important next component

    • allows editing user profiles
    • assign roles/teams/groups
    • view activity
  3. build invite dialog - enables adding new users

    • email validation
    • role selection
    • organization assignment
  4. configure workos - when ready for real auth

    • set up dashboard
    • update credentials
    • test login flow
  5. deploy - when ready

    • migrate prod database
    • set prod secrets
    • deploy to cloudflare

the foundation is solid. remaining work is primarily ui polish and workos configuration.