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

Method createAgent

packages/agent-core/src/session/index.ts:501–527  ·  view source on GitHub ↗
(
    config: Partial<AgentOptions>,
    options: CreateAgentOptions = {},
  )

Source from the content-addressed store, hash-verified

499 }
500
501 async createAgent(
502 config: Partial<AgentOptions>,
503 options: CreateAgentOptions = {},
504 ): Promise<{ readonly id: string; readonly agent: Agent }> {
505 await this.skillsReady;
506 const type = config.type ?? 'main';
507 const id = type === 'main' ? 'main' : this.nextGeneratedAgentId();
508 const homedir = config.homedir ?? join(this.options.homedir, 'agents', id);
509 const parentAgentId = options.parentAgentId ?? null;
510 const agent = this.instantiateAgent(id, homedir, type, config, parentAgentId);
511 if (options.profile) {
512 await this.bootstrapAgentProfile(agent, options.profile);
513 }
514
515 this.agents.set(id, agent);
516 if (options.persistMetadata !== false) {
517 this.metadata.agents[id] = {
518 homedir,
519 type,
520 parentAgentId,
521 swarmItem: options.swarmItem,
522 };
523 void this.writeMetadata();
524 }
525
526 return { id, agent };
527 }
528
529 async ensureAgentResumed(id: string): Promise<Agent> {
530 const entry = this.agents.get(id);

Callers 8

createMainMethod · 0.95
setupSessionFunction · 0.80
init.test.tsFile · 0.80
spawnMethod · 0.80
startBtwMethod · 0.80

Calls 5

nextGeneratedAgentIdMethod · 0.95
instantiateAgentMethod · 0.95
bootstrapAgentProfileMethod · 0.95
writeMetadataMethod · 0.95
setMethod · 0.65

Tested by 1

setupSessionFunction · 0.64