forked from Lilly-Protocol/agentlily-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.ts
More file actions
61 lines (58 loc) · 1.89 KB
/
Copy pathbootstrap.ts
File metadata and controls
61 lines (58 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { AgentInstanceManager } from "../agents/agent-instance-manager.js";
import { ActionExecutor } from "../actions/action-executor.js";
import { RuntimeEventBus } from "../events/runtime-events.js";
import { ConsoleRuntimeLogger } from "../logger/runtime-logger.js";
import {
InMemoryMemoryStore,
JsonFileMemoryStore
} from "../memory/memory-store.js";
import { UnconfiguredModelProvider } from "../providers/model-provider.js";
import { InMemoryRuntimeStateStore } from "../state/runtime-state.js";
import { TaskRunner } from "../tasks/task-runner.js";
import { ToolRegistry } from "../tools/tool-registry.js";
import type { RuntimeOptions } from "./types.js";
export function createRuntimeDependencies(options: RuntimeOptions) {
const toolRegistry = new ToolRegistry();
if (options.tools !== undefined) {
for (const tool of options.tools) {
toolRegistry.register(tool);
}
}
const memoryStore =
options.memoryStore ??
(options.memoryStoragePath
? new JsonFileMemoryStore(options.memoryStoragePath)
: new InMemoryMemoryStore());
const modelProvider =
options.modelProvider ?? new UnconfiguredModelProvider();
const logger = options.logger ?? new ConsoleRuntimeLogger();
const stateStore = options.stateStore ?? new InMemoryRuntimeStateStore();
const eventBus = options.eventBus ?? new RuntimeEventBus();
const agentManager = new AgentInstanceManager(
options.maxAgentInstances !== undefined
? { maxInstances: options.maxAgentInstances }
: {}
);
const actionExecutor = new ActionExecutor(
toolRegistry,
options.maxToolCallsPerTask,
eventBus,
logger
);
const taskRunner = new TaskRunner(
actionExecutor,
memoryStore,
options.maxTaskDurationMs
);
return {
actionExecutor,
agentManager,
eventBus,
logger,
memoryStore,
modelProvider,
stateStore,
taskRunner,
toolRegistry
};
}