dsh-brain/lib/entries/memory.js

20 lines
803 B
JavaScript

import { brainKernel } from "../kernel.js";
import { createMemoryTools } from "../memory/tools.js";
export const name = 'dsh-brain-memory';
/** Services required before `apply` runs. */
export const inject = ['tools'];
/** Register the sub-plugin with the host. */
export function apply(ctx, config) {
const kernel = brainKernel(config, ctx.logger('dsh-brain'));
kernel.activate('memory');
ctx.effect(() => () => kernel.deactivate('memory'), 'dsh-brain-memory: activation');
ctx.inject(['tools'], (toolsCtx) => {
const tools = toolsCtx.tools;
if (tools === undefined)
return;
for (const tool of createMemoryTools(kernel.toolDeps())) {
toolsCtx.effect(() => tools.register(tool), `dsh-brain-memory: tool ${tool.name}`);
}
});
}