Bin
2025-12-17 1d710f844b65d9bfdf986a71a3b924cd70598a41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { ff } from "@humansignal/core";
import { types } from "mobx-state-tree";
import ToolsManager from "../tools/Manager";
import * as Tools from "../tools";
import { FF_DEV_3391 } from "../utils/feature-flags";
 
export const ToolManagerMixin = types.model().actions((self) => {
  return {
    afterAttach() {
      if (ff.isActive(FF_DEV_3391) && self.annotationStore.initialized) {
        self.tools = self.annotationStore.names.get(self.name).tools;
        return;
      }
      const toolNames = self.toolNames ?? [];
      const manager = ToolsManager.getInstance({ name: self.toname });
      const env = { manager, control: self };
      const tools = {};
 
      toolNames.forEach((toolName) => {
        if (toolName in Tools) {
          const tool = Tools[toolName].create({}, env);
 
          tools[toolName] = tool;
        }
      });
 
      self.tools = tools;
 
      // copy tools from control tags into object tools manager
      // [DOCS] each object tag may have an assigned tools
      // manager. This assignment may happen because user asked
      // for it through the config, or because the attached
      // control tags are complex and require additional UI
      // interfaces. Each control tag defines a set of tools it
      // supports
      manager.addToolsFromControl(self);
    },
  };
});