MCPcopy Create free account
hub / github.com/chieapp/chie / createAssistant

Method createAssistant

src/controller/assistant-manager.ts:95–109  ·  view source on GitHub ↗
(name: string, serviceName: string, credential: APICredential, viewClass: BaseViewType, options?: Partial<WebServiceOptions>)

Source from the content-addressed store, hash-verified

93 }
94
95 createAssistant(name: string, serviceName: string, credential: APICredential, viewClass: BaseViewType, options?: Partial<WebServiceOptions>) {
96 const service = serviceManager.createService(name, serviceName, credential, options);
97 // Do runtime check of API type compatibility.
98 const {viewClasses} = serviceManager.getServiceByName(serviceName);
99 if (!viewClasses.find(V => matchClass(V, viewClass)))
100 throw new Error(`Service "${service.constructor.name}" does not support View type "${viewClass.name}".`);
101 // Create a new assistant of service.
102 const ids = this.#assistants.map(assistant => assistant.id);
103 const id = getNextId(service.name, ids);
104 const assistant = new Assistant(id, service, viewClass);
105 this.#assistants.push(assistant);
106 this.onNewAssistant.emit(assistant, ids.length);
107 this.saveConfig();
108 return assistant;
109 }
110
111 removeAssistantById(id: string) {
112 const index = this.#assistants.findIndex(assistant => assistant.id == id);

Callers 7

app-tray-test.tsFile · 0.80
#onSubmitMethod · 0.80
#onSubmitMethod · 0.80

Calls 4

matchClassFunction · 0.90
getNextIdFunction · 0.90
createServiceMethod · 0.80
getServiceByNameMethod · 0.80

Tested by

no test coverage detected