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.

801 B
Raw Blame
import { CanvasIdentifier } from '@lobechat/builtin-tool-canvas';

import { createCanvasAgentRuntime } from '@/server/services/canvas/agentRuntime';

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

export const canvasRuntime: ServerRuntimeRegistration = {
  factory: async (context) => {
    if (!context.userId || !context.serverDB) {
      throw new Error('userId and serverDB are required for Canvas tool execution');
    }

    return createCanvasAgentRuntime(context.serverDB, {
      agentId: context.agentId,
      threadId: context.threadId,
      topicId: context.topicId,
      userId: context.userId,
      workspaceId: await resolveContentWorkspaceId(context),
    });
  },
  identifier: CanvasIdentifier,
};