mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-12 05:55:02 +10:00
6d8d8f6e55
* 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
222 lines
4.8 KiB
TypeScript
222 lines
4.8 KiB
TypeScript
import { defineRelations } from "drizzle-orm";
|
|
import * as schema from "./schema";
|
|
|
|
export const relations = defineRelations(schema, (r) => ({
|
|
user: {
|
|
sessions: r.many.session(),
|
|
accounts: r.many.account(),
|
|
twoFactors: r.many.twoFactor(),
|
|
passkeys: r.many.passkey(),
|
|
resumes: r.many.resume(),
|
|
aiProviders: r.many.aiProvider(),
|
|
agentThreads: r.many.agentThread(),
|
|
agentMessages: r.many.agentMessage(),
|
|
agentAttachments: r.many.agentAttachment(),
|
|
agentActions: r.many.agentAction(),
|
|
apiKeys: r.many.apikey(),
|
|
oauthClients: r.many.oauthClient(),
|
|
oauthRefreshTokens: r.many.oauthRefreshToken(),
|
|
oauthAccessTokens: r.many.oauthAccessToken(),
|
|
oauthConsents: r.many.oauthConsent(),
|
|
},
|
|
session: {
|
|
user: r.one.user({
|
|
from: r.session.userId,
|
|
to: r.user.id,
|
|
}),
|
|
oauthRefreshTokens: r.many.oauthRefreshToken({
|
|
from: r.session.id,
|
|
to: r.oauthRefreshToken.sessionId,
|
|
}),
|
|
oauthAccessTokens: r.many.oauthAccessToken({
|
|
from: r.session.id,
|
|
to: r.oauthAccessToken.sessionId,
|
|
}),
|
|
},
|
|
account: {
|
|
user: r.one.user({
|
|
from: r.account.userId,
|
|
to: r.user.id,
|
|
}),
|
|
},
|
|
twoFactor: {
|
|
user: r.one.user({
|
|
from: r.twoFactor.userId,
|
|
to: r.user.id,
|
|
}),
|
|
},
|
|
passkey: {
|
|
user: r.one.user({
|
|
from: r.passkey.userId,
|
|
to: r.user.id,
|
|
}),
|
|
},
|
|
resume: {
|
|
user: r.one.user({
|
|
from: r.resume.userId,
|
|
to: r.user.id,
|
|
}),
|
|
statistics: r.one.resumeStatistics({
|
|
from: r.resume.id,
|
|
to: r.resumeStatistics.resumeId,
|
|
}),
|
|
analysis: r.one.resumeAnalysis({
|
|
from: r.resume.id,
|
|
to: r.resumeAnalysis.resumeId,
|
|
}),
|
|
sourceAgentThreads: r.many.agentThread({
|
|
from: r.resume.id,
|
|
to: r.agentThread.sourceResumeId,
|
|
}),
|
|
workingAgentThreads: r.many.agentThread({
|
|
from: r.resume.id,
|
|
to: r.agentThread.workingResumeId,
|
|
}),
|
|
agentActions: r.many.agentAction({
|
|
from: r.resume.id,
|
|
to: r.agentAction.resumeId,
|
|
}),
|
|
},
|
|
resumeStatistics: {
|
|
resume: r.one.resume({
|
|
from: r.resumeStatistics.resumeId,
|
|
to: r.resume.id,
|
|
}),
|
|
},
|
|
resumeAnalysis: {
|
|
resume: r.one.resume({
|
|
from: r.resumeAnalysis.resumeId,
|
|
to: r.resume.id,
|
|
}),
|
|
},
|
|
aiProvider: {
|
|
user: r.one.user({
|
|
from: r.aiProvider.userId,
|
|
to: r.user.id,
|
|
}),
|
|
threads: r.many.agentThread({
|
|
from: r.aiProvider.id,
|
|
to: r.agentThread.aiProviderId,
|
|
}),
|
|
},
|
|
agentThread: {
|
|
user: r.one.user({
|
|
from: r.agentThread.userId,
|
|
to: r.user.id,
|
|
}),
|
|
aiProvider: r.one.aiProvider({
|
|
from: r.agentThread.aiProviderId,
|
|
to: r.aiProvider.id,
|
|
}),
|
|
sourceResume: r.one.resume({
|
|
from: r.agentThread.sourceResumeId,
|
|
to: r.resume.id,
|
|
}),
|
|
workingResume: r.one.resume({
|
|
from: r.agentThread.workingResumeId,
|
|
to: r.resume.id,
|
|
}),
|
|
messages: r.many.agentMessage(),
|
|
attachments: r.many.agentAttachment(),
|
|
actions: r.many.agentAction(),
|
|
},
|
|
agentMessage: {
|
|
user: r.one.user({
|
|
from: r.agentMessage.userId,
|
|
to: r.user.id,
|
|
}),
|
|
thread: r.one.agentThread({
|
|
from: r.agentMessage.threadId,
|
|
to: r.agentThread.id,
|
|
}),
|
|
attachments: r.many.agentAttachment(),
|
|
actions: r.many.agentAction(),
|
|
},
|
|
agentAttachment: {
|
|
user: r.one.user({
|
|
from: r.agentAttachment.userId,
|
|
to: r.user.id,
|
|
}),
|
|
thread: r.one.agentThread({
|
|
from: r.agentAttachment.threadId,
|
|
to: r.agentThread.id,
|
|
}),
|
|
message: r.one.agentMessage({
|
|
from: r.agentAttachment.messageId,
|
|
to: r.agentMessage.id,
|
|
}),
|
|
},
|
|
agentAction: {
|
|
user: r.one.user({
|
|
from: r.agentAction.userId,
|
|
to: r.user.id,
|
|
}),
|
|
thread: r.one.agentThread({
|
|
from: r.agentAction.threadId,
|
|
to: r.agentThread.id,
|
|
}),
|
|
message: r.one.agentMessage({
|
|
from: r.agentAction.messageId,
|
|
to: r.agentMessage.id,
|
|
}),
|
|
resume: r.one.resume({
|
|
from: r.agentAction.resumeId,
|
|
to: r.resume.id,
|
|
}),
|
|
},
|
|
apikey: {
|
|
user: r.one.user({
|
|
from: r.apikey.referenceId,
|
|
to: r.user.id,
|
|
}),
|
|
},
|
|
oauthClient: {
|
|
user: r.one.user({
|
|
from: r.oauthClient.userId,
|
|
to: r.user.id,
|
|
}),
|
|
oauthRefreshTokens: r.many.oauthRefreshToken({
|
|
from: r.oauthClient.clientId,
|
|
to: r.oauthRefreshToken.clientId,
|
|
}),
|
|
oauthAccessTokens: r.many.oauthAccessToken({
|
|
from: r.oauthClient.clientId,
|
|
to: r.oauthAccessToken.clientId,
|
|
}),
|
|
oauthConsents: r.many.oauthConsent({
|
|
from: r.oauthClient.clientId,
|
|
to: r.oauthConsent.clientId,
|
|
}),
|
|
},
|
|
oauthRefreshToken: {
|
|
user: r.one.user({
|
|
from: r.oauthRefreshToken.userId,
|
|
to: r.user.id,
|
|
}),
|
|
session: r.one.session({
|
|
from: r.oauthRefreshToken.sessionId,
|
|
to: r.session.id,
|
|
}),
|
|
},
|
|
oauthAccessToken: {
|
|
user: r.one.user({
|
|
from: r.oauthAccessToken.userId,
|
|
to: r.user.id,
|
|
}),
|
|
session: r.one.session({
|
|
from: r.oauthAccessToken.sessionId,
|
|
to: r.session.id,
|
|
}),
|
|
refreshToken: r.one.oauthRefreshToken({
|
|
from: r.oauthAccessToken.refreshId,
|
|
to: r.oauthRefreshToken.id,
|
|
}),
|
|
},
|
|
oauthConsent: {
|
|
user: r.one.user({
|
|
from: r.oauthConsent.userId,
|
|
to: r.user.id,
|
|
}),
|
|
},
|
|
}));
|