Skip to content

Commit dd4f86c

Browse files
feat(questionnaire): add security questionnaire feature with AI parsing and auto-answering (#1755)
- Add questionnaire file upload and parsing functionality - Implement AI-powered question extraction from PDFs - Add auto-answer functionality using RAG with vector embeddings - Add questionnaire results display, editing, and export - Implement vector embedding sync for organization policies - Add batch processing for questionnaire answers - Fix TypeScript build error in analytics package - Resolve merge conflict in bun.lock Co-authored-by: Tofik Hasanov <annexcies@gmail.com>
1 parent fb1032c commit dd4f86c

35 files changed

+4428
-1728
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@ packages/*/dist
8484
**/src/db/generated/
8585

8686
# Release script
87-
scripts/sync-release-branch.sh
87+
scripts/sync-release-branch.sh
88+
/.vscode

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"[typescriptreact]": {
2525
"editor.defaultFormatter": "esbenp.prettier-vscode"
26-
}
26+
},
27+
"typescript.tsserver.experimental.enableProjectDiagnostics": true
2728
}

apps/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"next-safe-action": "^8.0.3",
8181
"next-themes": "^0.4.4",
8282
"nuqs": "^2.4.3",
83+
"pdf-parse": "^2.4.5",
8384
"playwright-core": "^1.52.0",
8485
"posthog-js": "^1.236.6",
8586
"posthog-node": "^5.8.2",
77.1 KB
Loading
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
'use server';
2+
3+
import { auth as betterAuth } from '@/utils/auth';
4+
import { auth } from '@trigger.dev/sdk';
5+
import { headers } from 'next/headers';
6+
7+
// Create trigger token for auto-answer (can trigger and read)
8+
export const createTriggerToken = async (taskId: 'parse-questionnaire' | 'vendor-questionnaire-orchestrator' | 'answer-question') => {
9+
const session = await betterAuth.api.getSession({
10+
headers: await headers(),
11+
});
12+
13+
if (!session) {
14+
return {
15+
success: false,
16+
error: 'Unauthorized',
17+
};
18+
}
19+
20+
const orgId = session.session?.activeOrganizationId;
21+
if (!orgId) {
22+
return {
23+
success: false,
24+
error: 'No active organization',
25+
};
26+
}
27+
28+
try {
29+
const token = await auth.createTriggerPublicToken(taskId, {
30+
multipleUse: true,
31+
expirationTime: '1hr',
32+
});
33+
34+
return {
35+
success: true,
36+
token,
37+
};
38+
} catch (error) {
39+
console.error('Error creating trigger token:', error);
40+
return {
41+
success: false,
42+
error: error instanceof Error ? error.message : 'Failed to create trigger token',
43+
};
44+
}
45+
};
46+
47+
// Create public token with read permissions for a specific run
48+
export const createRunReadToken = async (runId: string) => {
49+
const session = await betterAuth.api.getSession({
50+
headers: await headers(),
51+
});
52+
53+
if (!session) {
54+
return {
55+
success: false,
56+
error: 'Unauthorized',
57+
};
58+
}
59+
60+
try {
61+
const token = await auth.createPublicToken({
62+
scopes: {
63+
read: {
64+
runs: [runId],
65+
},
66+
},
67+
expirationTime: '1hr',
68+
});
69+
70+
return {
71+
success: true,
72+
token,
73+
};
74+
} catch (error) {
75+
console.error('Error creating run read token:', error);
76+
return {
77+
success: false,
78+
error: error instanceof Error ? error.message : 'Failed to create run read token',
79+
};
80+
}
81+
};
82+

0 commit comments

Comments
 (0)