feat: add AI agent workspace (#3062)

* chore(ai): remove local AI store now that providers live server-side

The Zustand-based useAIStore has been replaced by the server-side
aiProviders oRPC router (encrypted credentials persisted in DB).
Delete the dead store + tests, drop the ./store export, and remove
zustand/immer deps which are no longer referenced anywhere in
packages/ai/src/.

* feat(agent): archive/delete actions and read-only state for agent threads

- Backend: mark archived threads as read-only in threads.get and reject
  messages.send with CONFLICT when the thread is archived.
- Frontend: render archived threads in the sidebar with muted styling and
  an Archived badge; add a per-thread dropdown menu in the chat header
  with Archive (non-destructive) and Delete (with confirmation); show a
  read-only banner above the message list that disambiguates archived
  vs. missing-resource causes; suppress the Retry and Stop buttons in
  read-only mode.
- Tests: new packages/api/src/services/agent.test.ts covering the
  archived-thread isReadOnly flag and the archived-thread send refusal.

* fix(agent): abort run on archive and verify ownership before deleting thread

- threads.archive: before flipping status, abort any in-flight run controller
  and clear the active-run state on the thread; cleanup failures are logged
  but do not block the status update.
- threads.delete: assert thread ownership via getThread before destructive
  work so an authenticated user cannot wipe another user's attachment rows
  by passing a foreign threadId.

Adds focused tests for both behaviors.

* feat(agent): display patch diffs and surface revert conflicts

Render apply_resume_patch tool messages with a status-aware card (applied/
reverted/conflicted), expandable operation list, and a Revert button that
correctly handles RESUME_VERSION_CONFLICT responses. Adds unit tests for
the inverse-patch builder and the agentService.actions.revert flow.

* chore(agent): remove out-of-scope attachment tests accidentally added in Task 6

The Task 6 commit (73ef1acca) accidentally re-introduced three attachment-
related tests that belong to a separate task:

- `buildAttachmentModelParts > converts text, image, supported binary, and
  unsupported attachments into model parts`
- `agentService.messages.send > persists the user message with file UI parts
  and links selected attachments to it` (was failing — the `ToolLoopAgent`
  mock is not callable as a constructor)
- `agentService.messages.send > rejects attachments that are missing, foreign,
  or already linked before persisting a message`

These were likely re-added during a stash recovery and were not requested
for Task 6, whose scope was limited to the `agentService.actions.revert`
flow. Remove them along with the helpers/fixtures (`buildAttachment`,
`buildActiveThread`, `selectWhereResult`, `selectOrderByResult`) that they
were the only consumers of. `selectLimitResult` is preserved because it is
used by the revert tests.

* chore(agent): configure runtime dependencies

* feat(db): add agent workspace schema

* feat(api): add agent backend services

* feat(web): add agent workspace UI

* chore(agent): remove legacy builder assistant

* test(agent): make agent stream mocks constructible

* chore(web): remove unused resume replacement hook

* feat(api): add unsafe AI base URL flag

* chore(dev): expose local services in compose

* fix(web): normalize resume preview gaps

* feat(api): improve agent tool handling

* feat(web): polish agent workspace UI

* chore: update dependencies

* fix(api,web): address PR review feedback for agent workspace

Security/correctness:
- Restrict AI provider URLs to http/https even in unsafe mode
- Stop exposing Redis on host network by default
- Make .env.local optional and drop app profile in compose.dev.yml
- Store agent attachments with private ACL on S3
- Reset provider test status when provider/model/baseURL changes
- Decouple non-agent AI endpoints from REDIS_URL requirement
- Fix JSON Patch add inverse for existing object members
- Wrap resume patch + agent action insert in db transaction
- Validate partialMessage at runtime and rate-limit attachment uploads
- Add unique index on agent_messages (thread_id, sequence)

UX/bugs:
- Mark agent thread route as ssr: false and guard SSE chunk parsing
- Show config-specific banner only on known configuration error
- Gate AI provider checks behind loading state in resume import
- Fix relative-time formatter blank gap between 45-59 seconds
- Clarify thread delete confirmation message

Polish:
- Raise ENCRYPTION_SECRET minimum to 32 characters
- Bucket AI rate limits by resumeId/threadId/messageId
- Trim form values before submitting AI provider config
- Use single key identifier and nullish-coalesce baseURL display

* fix: address ai agent review feedback

* fix: preserve mobile agent chat state

* docs: add ai agent workspace guides

* feat: introduce design system for Reactive Resume
This commit is contained in:
Amruth Pillai
2026-05-14 15:00:04 +02:00
committed by GitHub
parent 22c60c64b6
commit 6d8d8f6e55
115 changed files with 15623 additions and 2123 deletions
+92
View File
@@ -12,10 +12,12 @@ import { Route as rootRouteImport } from './routes/__root'
import { Route as SchemaDotjsonRouteImport } from './routes/schema[.]json'
import { Route as DashboardRouteRouteImport } from './routes/dashboard/route'
import { Route as AuthRouteRouteImport } from './routes/auth/route'
import { Route as AgentRouteRouteImport } from './routes/agent/route'
import { Route as HomeRouteRouteImport } from './routes/_home/route'
import { Route as McpIndexRouteImport } from './routes/mcp/index'
import { Route as DashboardIndexRouteImport } from './routes/dashboard/index'
import { Route as AuthIndexRouteImport } from './routes/auth/index'
import { Route as AgentIndexRouteImport } from './routes/agent/index'
import { Route as HomeIndexRouteImport } from './routes/_home/index'
import { Route as TemplatesSplatRouteImport } from './routes/templates/$'
import { Route as AuthVerify2faBackupRouteImport } from './routes/auth/verify-2fa-backup'
@@ -27,6 +29,8 @@ import { Route as AuthOauthRouteImport } from './routes/auth/oauth'
import { Route as AuthLoginRouteImport } from './routes/auth/login'
import { Route as AuthForgotPasswordRouteImport } from './routes/auth/forgot-password'
import { Route as ApiHealthRouteImport } from './routes/api/health'
import { Route as AgentNewRouteImport } from './routes/agent/new'
import { Route as AgentThreadIdRouteImport } from './routes/agent/$threadId'
import { Route as DotwellKnownOpenidConfigurationRouteImport } from './routes/[.]well-known/openid-configuration'
import { Route as DotwellKnownOauthProtectedResourceRouteImport } from './routes/[.]well-known/oauth-protected-resource'
import { Route as DotwellKnownOauthAuthorizationServerRouteImport } from './routes/[.]well-known/oauth-authorization-server'
@@ -66,6 +70,11 @@ const AuthRouteRoute = AuthRouteRouteImport.update({
path: '/auth',
getParentRoute: () => rootRouteImport,
} as any)
const AgentRouteRoute = AgentRouteRouteImport.update({
id: '/agent',
path: '/agent',
getParentRoute: () => rootRouteImport,
} as any)
const HomeRouteRoute = HomeRouteRouteImport.update({
id: '/_home',
getParentRoute: () => rootRouteImport,
@@ -85,6 +94,11 @@ const AuthIndexRoute = AuthIndexRouteImport.update({
path: '/',
getParentRoute: () => AuthRouteRoute,
} as any)
const AgentIndexRoute = AgentIndexRouteImport.update({
id: '/',
path: '/',
getParentRoute: () => AgentRouteRoute,
} as any)
const HomeIndexRoute = HomeIndexRouteImport.update({
id: '/',
path: '/',
@@ -140,6 +154,16 @@ const ApiHealthRoute = ApiHealthRouteImport.update({
path: '/api/health',
getParentRoute: () => rootRouteImport,
} as any)
const AgentNewRoute = AgentNewRouteImport.update({
id: '/new',
path: '/new',
getParentRoute: () => AgentRouteRoute,
} as any)
const AgentThreadIdRoute = AgentThreadIdRouteImport.update({
id: '/$threadId',
path: '/$threadId',
getParentRoute: () => AgentRouteRoute,
} as any)
const DotwellKnownOpenidConfigurationRoute =
DotwellKnownOpenidConfigurationRouteImport.update({
id: '/.well-known/openid-configuration',
@@ -271,6 +295,7 @@ const ApiUploadsUserIdSplatRoute = ApiUploadsUserIdSplatRouteImport.update({
export interface FileRoutesByFullPath {
'/': typeof HomeIndexRoute
'/agent': typeof AgentRouteRouteWithChildren
'/auth': typeof AuthRouteRouteWithChildren
'/dashboard': typeof DashboardRouteRouteWithChildren
'/schema.json': typeof SchemaDotjsonRoute
@@ -280,6 +305,8 @@ export interface FileRoutesByFullPath {
'/.well-known/oauth-authorization-server': typeof DotwellKnownOauthAuthorizationServerRouteWithChildren
'/.well-known/oauth-protected-resource': typeof DotwellKnownOauthProtectedResourceRouteWithChildren
'/.well-known/openid-configuration': typeof DotwellKnownOpenidConfigurationRoute
'/agent/$threadId': typeof AgentThreadIdRoute
'/agent/new': typeof AgentNewRoute
'/api/health': typeof ApiHealthRoute
'/auth/forgot-password': typeof AuthForgotPasswordRoute
'/auth/login': typeof AuthLoginRoute
@@ -290,6 +317,7 @@ export interface FileRoutesByFullPath {
'/auth/verify-2fa': typeof AuthVerify2faRoute
'/auth/verify-2fa-backup': typeof AuthVerify2faBackupRoute
'/templates/$': typeof TemplatesSplatRoute
'/agent/': typeof AgentIndexRoute
'/auth/': typeof AuthIndexRoute
'/dashboard/': typeof DashboardIndexRoute
'/mcp/': typeof McpIndexRoute
@@ -318,6 +346,8 @@ export interface FileRoutesByTo {
'/.well-known/oauth-authorization-server': typeof DotwellKnownOauthAuthorizationServerRouteWithChildren
'/.well-known/oauth-protected-resource': typeof DotwellKnownOauthProtectedResourceRouteWithChildren
'/.well-known/openid-configuration': typeof DotwellKnownOpenidConfigurationRoute
'/agent/$threadId': typeof AgentThreadIdRoute
'/agent/new': typeof AgentNewRoute
'/api/health': typeof ApiHealthRoute
'/auth/forgot-password': typeof AuthForgotPasswordRoute
'/auth/login': typeof AuthLoginRoute
@@ -329,6 +359,7 @@ export interface FileRoutesByTo {
'/auth/verify-2fa-backup': typeof AuthVerify2faBackupRoute
'/templates/$': typeof TemplatesSplatRoute
'/': typeof HomeIndexRoute
'/agent': typeof AgentIndexRoute
'/auth': typeof AuthIndexRoute
'/dashboard': typeof DashboardIndexRoute
'/mcp': typeof McpIndexRoute
@@ -353,6 +384,7 @@ export interface FileRoutesByTo {
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/_home': typeof HomeRouteRouteWithChildren
'/agent': typeof AgentRouteRouteWithChildren
'/auth': typeof AuthRouteRouteWithChildren
'/dashboard': typeof DashboardRouteRouteWithChildren
'/schema.json': typeof SchemaDotjsonRoute
@@ -362,6 +394,8 @@ export interface FileRoutesById {
'/.well-known/oauth-authorization-server': typeof DotwellKnownOauthAuthorizationServerRouteWithChildren
'/.well-known/oauth-protected-resource': typeof DotwellKnownOauthProtectedResourceRouteWithChildren
'/.well-known/openid-configuration': typeof DotwellKnownOpenidConfigurationRoute
'/agent/$threadId': typeof AgentThreadIdRoute
'/agent/new': typeof AgentNewRoute
'/api/health': typeof ApiHealthRoute
'/auth/forgot-password': typeof AuthForgotPasswordRoute
'/auth/login': typeof AuthLoginRoute
@@ -373,6 +407,7 @@ export interface FileRoutesById {
'/auth/verify-2fa-backup': typeof AuthVerify2faBackupRoute
'/templates/$': typeof TemplatesSplatRoute
'/_home/': typeof HomeIndexRoute
'/agent/': typeof AgentIndexRoute
'/auth/': typeof AuthIndexRoute
'/dashboard/': typeof DashboardIndexRoute
'/mcp/': typeof McpIndexRoute
@@ -398,6 +433,7 @@ export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths:
| '/'
| '/agent'
| '/auth'
| '/dashboard'
| '/schema.json'
@@ -407,6 +443,8 @@ export interface FileRouteTypes {
| '/.well-known/oauth-authorization-server'
| '/.well-known/oauth-protected-resource'
| '/.well-known/openid-configuration'
| '/agent/$threadId'
| '/agent/new'
| '/api/health'
| '/auth/forgot-password'
| '/auth/login'
@@ -417,6 +455,7 @@ export interface FileRouteTypes {
| '/auth/verify-2fa'
| '/auth/verify-2fa-backup'
| '/templates/$'
| '/agent/'
| '/auth/'
| '/dashboard/'
| '/mcp/'
@@ -445,6 +484,8 @@ export interface FileRouteTypes {
| '/.well-known/oauth-authorization-server'
| '/.well-known/oauth-protected-resource'
| '/.well-known/openid-configuration'
| '/agent/$threadId'
| '/agent/new'
| '/api/health'
| '/auth/forgot-password'
| '/auth/login'
@@ -456,6 +497,7 @@ export interface FileRouteTypes {
| '/auth/verify-2fa-backup'
| '/templates/$'
| '/'
| '/agent'
| '/auth'
| '/dashboard'
| '/mcp'
@@ -479,6 +521,7 @@ export interface FileRouteTypes {
id:
| '__root__'
| '/_home'
| '/agent'
| '/auth'
| '/dashboard'
| '/schema.json'
@@ -488,6 +531,8 @@ export interface FileRouteTypes {
| '/.well-known/oauth-authorization-server'
| '/.well-known/oauth-protected-resource'
| '/.well-known/openid-configuration'
| '/agent/$threadId'
| '/agent/new'
| '/api/health'
| '/auth/forgot-password'
| '/auth/login'
@@ -499,6 +544,7 @@ export interface FileRouteTypes {
| '/auth/verify-2fa-backup'
| '/templates/$'
| '/_home/'
| '/agent/'
| '/auth/'
| '/dashboard/'
| '/mcp/'
@@ -523,6 +569,7 @@ export interface FileRouteTypes {
}
export interface RootRouteChildren {
HomeRouteRoute: typeof HomeRouteRouteWithChildren
AgentRouteRoute: typeof AgentRouteRouteWithChildren
AuthRouteRoute: typeof AuthRouteRouteWithChildren
DashboardRouteRoute: typeof DashboardRouteRouteWithChildren
SchemaDotjsonRoute: typeof SchemaDotjsonRoute
@@ -566,6 +613,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AuthRouteRouteImport
parentRoute: typeof rootRouteImport
}
'/agent': {
id: '/agent'
path: '/agent'
fullPath: '/agent'
preLoaderRoute: typeof AgentRouteRouteImport
parentRoute: typeof rootRouteImport
}
'/_home': {
id: '/_home'
path: ''
@@ -594,6 +648,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AuthIndexRouteImport
parentRoute: typeof AuthRouteRoute
}
'/agent/': {
id: '/agent/'
path: '/'
fullPath: '/agent/'
preLoaderRoute: typeof AgentIndexRouteImport
parentRoute: typeof AgentRouteRoute
}
'/_home/': {
id: '/_home/'
path: '/'
@@ -671,6 +732,20 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ApiHealthRouteImport
parentRoute: typeof rootRouteImport
}
'/agent/new': {
id: '/agent/new'
path: '/new'
fullPath: '/agent/new'
preLoaderRoute: typeof AgentNewRouteImport
parentRoute: typeof AgentRouteRoute
}
'/agent/$threadId': {
id: '/agent/$threadId'
path: '/$threadId'
fullPath: '/agent/$threadId'
preLoaderRoute: typeof AgentThreadIdRouteImport
parentRoute: typeof AgentRouteRoute
}
'/.well-known/openid-configuration': {
id: '/.well-known/openid-configuration'
path: '/.well-known/openid-configuration'
@@ -847,6 +922,22 @@ const HomeRouteRouteWithChildren = HomeRouteRoute._addFileChildren(
HomeRouteRouteChildren,
)
interface AgentRouteRouteChildren {
AgentThreadIdRoute: typeof AgentThreadIdRoute
AgentNewRoute: typeof AgentNewRoute
AgentIndexRoute: typeof AgentIndexRoute
}
const AgentRouteRouteChildren: AgentRouteRouteChildren = {
AgentThreadIdRoute: AgentThreadIdRoute,
AgentNewRoute: AgentNewRoute,
AgentIndexRoute: AgentIndexRoute,
}
const AgentRouteRouteWithChildren = AgentRouteRoute._addFileChildren(
AgentRouteRouteChildren,
)
interface AuthRouteRouteChildren {
AuthForgotPasswordRoute: typeof AuthForgotPasswordRoute
AuthLoginRoute: typeof AuthLoginRoute
@@ -948,6 +1039,7 @@ const DotwellKnownOauthProtectedResourceRouteWithChildren =
const rootRouteChildren: RootRouteChildren = {
HomeRouteRoute: HomeRouteRouteWithChildren,
AgentRouteRoute: AgentRouteRouteWithChildren,
AuthRouteRoute: AuthRouteRouteWithChildren,
DashboardRouteRoute: DashboardRouteRouteWithChildren,
SchemaDotjsonRoute: SchemaDotjsonRoute,