feat: HLS streaming, transcripts, agent course generation & landing-page course previews (#663)

New features:
- HLS video encoding/streaming (hls routes, hls-encoder) and a media
  transcripts pipeline (transcripts route + media-transcript queries)
- AI assistant chat vs. run model: agent-course-generation worker/queue,
  run-monitor pane, chat-changes card, content ask-ai bar
- Per-theme course-page previews across org landing-page themes (bold,
  classic, corporate, editorial, etc.) with a shared course token/component set
- View-as-student mode and login-link / link-invite invite flows

Refactor:
- Extract packages/core consolidating config (env, storage, dashboard-url),
  services and utils previously duplicated under apps/api/src/config
- Remove legacy agent service modules (chat-tools, chat-context,
  context-window, document, fetch-url, lesson-content)
- Relax Cross-Origin-Resource-Policy to allow cross-origin media embedding
- Add format script to tenant-router so turbo run format covers it
This commit is contained in:
Rotimi Best
2026-06-07 18:43:05 +01:00
committed by GitHub
parent a2e70779a0
commit d5b07d356e
496 changed files with 19050 additions and 8312 deletions
@@ -0,0 +1,25 @@
import type { JobsOptions } from 'bullmq';
import { JOB_NAMES, QUEUE_NAMES } from '../queues/names';
import { QUEUE_DEFAULTS } from '../queues/defaults';
import { getQueue } from '../queues/factories';
import type { TAgentCourseGenerationPayload } from '../payloads/agent-course-generation';
function toJobId(runId: string, attempt: number): string {
return `agent-course-generation-${runId}-${attempt}`;
}
export async function enqueueAgentCourseGenerationRun(
payload: TAgentCourseGenerationPayload,
options: { attempt: number } & JobsOptions
): Promise<string | undefined> {
const { attempt, ...jobOptions } = options;
const job = await getQueue(QUEUE_NAMES.agentCourseGeneration).add(JOB_NAMES.agentCourseGeneration.run, payload, {
...QUEUE_DEFAULTS[QUEUE_NAMES.agentCourseGeneration],
jobId: toJobId(payload.runId, attempt),
...jobOptions
});
return job.id;
}
+1
View File
@@ -1,2 +1,3 @@
export * from './media';
export * from './emails';
export * from './agent-course-generation';
@@ -0,0 +1,15 @@
import * as z from 'zod';
/**
* Payload for long-running AI course-generation runs.
*
* The worker re-loads the full run from Postgres by id. Keep the queue payload
* tiny so retries always use the latest durable run state and checkpoints.
*/
export const ZAgentCourseGenerationPayload = z.object({
runId: z.string().uuid(),
requestedByUserId: z.string().uuid(),
organizationId: z.string().uuid()
});
export type TAgentCourseGenerationPayload = z.infer<typeof ZAgentCourseGenerationPayload>;
+1
View File
@@ -1,3 +1,4 @@
export * from './media';
export * from './emails';
export * from './maintenance';
export * from './agent-course-generation';
@@ -23,6 +23,15 @@ export type TDeadLetterCleanupPayload = z.infer<typeof ZDeadLetterCleanupPayload
* stops blocking new runs after a worker crash, server restart, or lost
* BullMQ job.
*/
/**
* Daily aggregation of raw analytics page events into the daily rollup tables.
* Defaults to rolling up yesterday's data.
*/
export const ZAnalyticsDailyRollupPayload = z.object({
daysAgo: z.number().int().positive().default(1)
});
export type TAnalyticsDailyRollupPayload = z.infer<typeof ZAnalyticsDailyRollupPayload>;
export const ZMediaJobReapPayload = z.object({
staleAfterMinutes: z.number().int().positive().default(30)
});
+6
View File
@@ -47,6 +47,12 @@ export const QUEUE_DEFAULTS: Record<QueueName, JobsOptions> = {
removeOnComplete: { age: 7 * 86_400, count: 500 },
removeOnFail: { age: 14 * 86_400 }
},
[QUEUE_NAMES.agentCourseGeneration]: {
attempts: 3,
backoff: { type: 'exponential', delay: 60_000 },
removeOnComplete: { age: 7 * 86_400, count: 1_000 },
removeOnFail: { age: 14 * 86_400 }
},
[QUEUE_NAMES.onboardingBootstrap]: {
attempts: 3,
backoff: { type: 'exponential', delay: 30_000 },
+6 -1
View File
@@ -9,6 +9,7 @@ export const QUEUE_NAMES = {
notifications: 'notifications',
webhooks: 'webhooks',
courseImports: 'course-imports',
agentCourseGeneration: 'agent-course-generation',
onboardingBootstrap: 'onboarding-bootstrap',
maintenance: 'maintenance'
} as const;
@@ -35,9 +36,13 @@ export const JOB_NAMES = {
webhooks: {
deliver: 'deliver'
},
agentCourseGeneration: {
run: 'run'
},
maintenance: {
retentionCompact: 'retention-compact',
deadLetterCleanup: 'dead-letter-cleanup',
mediaJobReap: 'media-job-reap'
mediaJobReap: 'media-job-reap',
analyticsDailyRollup: 'analytics-daily-rollup'
}
} as const;