123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package agi
- import (
- "errors"
- "imuslab.com/arozos/mod/agi/static"
- )
- /*
- AGI Module Manager
- This interface handles the agi function module registartions
- and make sure the structures of all modules fits the pre-defined
- interface to be used by ArozOS Core system
- */
- // Lib interface, require vm, user, target system file handler and the vpath of the running script
- // This interface is called during injection (in user's term, require / import)
- // When called, the required agi function module will be injected into the virtual machine
- // which provide the function required for the vm code to interact with the real-systems
- type AgiLibInjectionIntergface func(*static.AgiLibInjectionPayload)
- type AgiLibInterface interface {
- GetLibraryID() string //Get the module unique name for import
- GetInjectFunction() AgiLibInjectionIntergface //Get the module injection point
- }
- // Register a library's identification name and its injection interface to the VM environment
- func (g *Gateway) RegisterLib(libname string, entryPoint AgiLibInjectionIntergface) error {
- _, ok := g.LoadedAGILibrary[libname]
- if ok {
- //This lib already registered. Return error
- return errors.New("This library name already registered")
- } else {
- g.LoadedAGILibrary[libname] = entryPoint
- }
- return nil
- }
- /*
- AGI Library Register List
- Add more library here if required
- */
- func (g *Gateway) LoadAllFunctionalModules() {
- g.ImageLibRegister()
- g.FileLibRegister()
- g.HTTPLibRegister()
- g.ShareLibRegister()
- g.IoTLibRegister()
- g.AppdataLibRegister()
- g.FFmpegLibRegister()
- }
|