/
githubmirror
/
ai-legion
Обзор
Документация
Войти
/
githubmirror
/
ai-legion
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/module/module-instance.ts
30 строк
756 B
eumemic
refactor rename
10 апр 2023, 23:57
10 апр 2023, 23:57
7c42bcd
Код
Авторство
О чём код?
import { ModuleContext, ModuleDefinition } from "."; import { ModuleManager } from "./module-manager"; export class ModuleInstance<S = void, A extends string = string> { private _state: S | undefined; constructor( private moduleManager: ModuleManager, public moduleDef: ModuleDefinition<S, A> ) {} get state(): S { if (!this.moduleDef.createState) return undefined as S; this._state = this.moduleDef.createState({ agentId: this.moduleManager.agentId, }); return this._state; } get context(): ModuleContext<S> { return { agentId: this.moduleManager.agentId, allAgentIds: this.moduleManager.allAgentIds, actionDictionary: this.moduleManager.actions, state: this.state, }; } }