Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

932 B
Raw Blame
import { NotebookIdentifier } from '@lobechat/builtin-tool-notebook';
import { NotebookExecutionRuntime } from '@lobechat/builtin-tool-notebook/executionRuntime';

import { NotebookRuntimeService } from '@/server/services/notebook';

import { type ServerRuntimeRegistration } from './types';

/**
 * Notebook Server Runtime
 * Per-request runtime (needs serverDB, userId, topicId)
 */
export const notebookRuntime: ServerRuntimeRegistration = {
  factory: (context) => {
    if (!context.userId || !context.serverDB) {
      throw new Error('userId and serverDB are required for Notebook execution');
    }

    const notebookService = new NotebookRuntimeService({
      callerAgentVisibility: context.agentVisibility,
      serverDB: context.serverDB,
      userId: context.userId,
      workspaceId: context.workspaceId,
    });

    return new NotebookExecutionRuntime(notebookService);
  },
  identifier: NotebookIdentifier,
};