MCPcopy Create free account
hub / github.com/cedriking/spark / ModuleInstance

Class ModuleInstance

src/module/module-instance.ts:4–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import { ModuleManager } from "./module-manager";
3
4export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected