Files
dataroom/features/ai/lib/trigger/add-file-to-vector-store.ts
zeekay caad90bc04 rip: enterprise dirs + paywalls — full AGPL, no commercial-license code
Drop the dual-licensed `ee/` tree entirely. All features previously
locked behind the Hanzo Dataroom Commercial License are now part of the
AGPL-3.0 core and freely available — custom domains, branded viewing,
advanced analytics, watermarks, access controls, Q&A, AI vector stores,
workflows, SAML SSO, dataroom invitations, conversations, templates.

Layout changes:
* `ee/features/{ai,conversations,workflows,permissions,storage,templates,
  dataroom-invitations,access-notifications,security,conversions}/` →
  `features/<name>/` (AGPL).
* `ee/limits/` → `lib/billing/limits/` with every plan resolving to an
  unlimited profile (no users/links/documents/domains/datarooms cap,
  conversations and watermarks always on).
* `ee/stripe/` → `lib/billing/legacy/` (already a compat shim over
  `@hanzoai/commerce`; renewal-reminder webhook is now a no-op).
* `ee/features/billing/cancellation/` deleted. Pause/unpause/cancel/
  retention routes now compile against `lib/billing/cancellation.ts`
  stubs that return 410 Gone; `isTeamPaused`/`isTeamPausedById` in
  `lib/billing/paused.ts` always report active. `CancellationModal` is
  a no-op shim in `components/billing/`.
* `app/(ee)/api/*` route group folded into `app/api/*` (SAML auth,
  SCIM, AI chat, workflows, FAQ, link-upload).

Build: `npm run build` green.
2026-06-07 11:46:48 -07:00

56 lines
1.6 KiB
TypeScript

import { logger, metadata, task } from "@trigger.dev/sdk/v3";
import { openai } from "@/features/ai/lib/models/openai";
import type { AddToVectorStorePayload } from "./types";
/**
* Add an existing OpenAI file to a vector store
* This is used when a document has already been processed and we just need to add it
* to a new vector store (e.g., when adding to a dataroom)
*/
export const addFileToVectorStoreTask = task({
id: "add-file-to-vector-store",
retry: { maxAttempts: 3 },
queue: {
concurrencyLimit: 10,
},
run: async (
payload: AddToVectorStorePayload,
): Promise<{ vectorStoreFileId: string }> => {
const { fileId, vectorStoreId, metadata: fileMetadata } = payload;
logger.info("Adding file to vector store", {
fileId,
vectorStoreId,
documentId: fileMetadata.documentId,
});
metadata.set("status", "indexing");
metadata.set("step", "Adding to vector store...");
metadata.set("progress", 80);
// Add file to vector store with metadata
const vectorStoreFile = await openai.vectorStores.files.create(
vectorStoreId,
{
file_id: fileId,
attributes: fileMetadata,
},
);
metadata.set("status", "completed");
metadata.set("step", "Indexed successfully");
metadata.set("progress", 100);
metadata.set("vectorStoreFileId", vectorStoreFile.id);
logger.info("File added to vector store successfully", {
fileId,
vectorStoreFileId: vectorStoreFile.id,
documentId: fileMetadata.documentId,
});
return { vectorStoreFileId: vectorStoreFile.id };
},
});