| 2 | import { ModuleManager } from "./module-manager"; |
| 3 | |
| 4 | export class ModuleInstance<S = void, A extends string = string> { |
| 5 | private _state: S | undefined; |
| 6 | |
| 7 | constructor( |
| 8 | private moduleManager: ModuleManager, |
| 9 | public moduleDef: ModuleDefinition<S, A> |
| 10 | ) {} |
| 11 | |
| 12 | get state(): S { |
| 13 | if (!this.moduleDef.createState) return undefined as S; |
| 14 | |
| 15 | this._state = this.moduleDef.createState({ |
| 16 | agentId: this.moduleManager.agentId, |
| 17 | }); |
| 18 | |
| 19 | return this._state; |
| 20 | } |
| 21 | |
| 22 | get context(): ModuleContext<S> { |
| 23 | return { |
| 24 | agentId: this.moduleManager.agentId, |
| 25 | allAgentIds: this.moduleManager.allAgentIds, |
| 26 | actionDictionary: this.moduleManager.actions, |
| 27 | state: this.state, |
| 28 | }; |
| 29 | } |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected