MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / constructor

Method constructor

packages/agent-core/src/session/index.ts:179–225  ·  view source on GitHub ↗
(public readonly options: SessionOptions)

Source from the content-addressed store, hash-verified

177 private agentsMdWarning: string | undefined;
178
179 constructor(public readonly options: SessionOptions) {
180 // Attach the per-session log sink up front so the constructor's
181 // fire-and-forget `loadSkills` / `loadMcpServers` failures (and
182 // anything else that races) land in the session log, not just global.
183 this.logHandle =
184 options.id === undefined
185 ? undefined
186 : getRootLogger().attachSession({
187 sessionId: options.id,
188 sessionDir: options.homedir,
189 });
190 this.log =
191 this.logHandle?.logger ??
192 (options.id === undefined ? log : log.createChild({ sessionId: options.id }));
193 this.rpc = options.rpc;
194 this.experimentalFlags = options.experimentalFlags ?? new FlagResolver();
195 this.hookEngine = new HookEngine(options.hooks, {
196 cwd: options.kaos.getcwd(),
197 sessionId: options.id,
198 });
199 this.telemetry = options.telemetry ?? noopTelemetryClient;
200 this.toolKaos = options.kaos;
201 this.persistenceKaos = options.persistenceKaos ?? options.kaos;
202 this.additionalDirs = normalizeAdditionalDirs(options.additionalDirs ?? []);
203 this.pluginCommands = options.pluginCommands ?? [];
204 this.skills = new SessionSkillRegistry({
205 sessionId: options.id,
206 });
207 this.mcp = new McpConnectionManager({
208 oauthService: new McpOAuthService({ kimiHomeDir: options.kimiHomeDir }),
209 log: this.log,
210 stdioCwd: options.kaos.getcwd(),
211 });
212 this.mcp.onStatusChange((entry) => {
213 this.onMcpServerStatusChange(entry);
214 });
215 this.skillsReady = this.loadSkills()
216 .catch((error: unknown) => {
217 this.log.error('skills load failed', error);
218 })
219 .then(() => {
220 this.refreshAgentBuiltinTools();
221 });
222 void this.loadMcpServers().catch((error: unknown) => {
223 this.emitInitialMcpLoadError(error);
224 });
225 }
226
227
228 setToolKaos(kaos: Kaos) {

Callers

nothing calls this directly

Calls 12

loadSkillsMethod · 0.95
loadMcpServersMethod · 0.95
getRootLoggerFunction · 0.90
normalizeAdditionalDirsFunction · 0.90
onStatusChangeMethod · 0.80
attachSessionMethod · 0.65
createChildMethod · 0.65
getcwdMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected