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

Function fakeSession

packages/agent-core/test/session/subagent-host.test.ts:1513–1565  ·  view source on GitHub ↗
(
  parent: Agent,
  child: Agent,
  metadataAgents: Session['metadata']['agents'] = {},
)

Source from the content-addressed store, hash-verified

1511});
1512
1513function fakeSession(
1514 parent: Agent,
1515 child: Agent,
1516 metadataAgents: Session['metadata']['agents'] = {},
1517) {
1518 const agents = new Map<string, Agent>([['main', parent]]);
1519 if (metadataAgents['agent-0'] !== undefined) {
1520 agents.set('agent-0', child);
1521 }
1522 return {
1523 agents,
1524 options: { kimiHomeDir: undefined },
1525 metadata: {
1526 createdAt: '2026-01-01T00:00:00.000Z',
1527 updatedAt: '2026-01-01T00:00:00.000Z',
1528 title: 'Test Session',
1529 isCustomTitle: false,
1530 agents: metadataAgents,
1531 custom: {},
1532 },
1533 writeMetadata: vi.fn(async () => {}),
1534 systemContextKaos: vi.fn((cwd: string) => parent.kaos.withCwd(cwd)),
1535 getReadyAgent: vi.fn((id: string) => agents.get(id)),
1536 ensureAgentResumed: vi.fn(async (id: string) => {
1537 const agent = agents.get(id);
1538 if (agent === undefined) {
1539 throw new Error(`Agent "${id}" was not found`);
1540 }
1541 return agent;
1542 }),
1543 createAgent: vi.fn(
1544 async (
1545 config: Parameters<Session['createAgent']>[0],
1546 options: Parameters<Session['createAgent']>[1] = {},
1547 ) => {
1548 agents.set('agent-0', child);
1549 const parentAgentId = options.parentAgentId ?? null;
1550 if (options.persistMetadata !== false) {
1551 metadataAgents['agent-0'] = {
1552 homedir: '/tmp/kimi-session/agents/agent-0',
1553 type: config.type ?? 'main',
1554 parentAgentId,
1555 swarmItem: options.swarmItem,
1556 };
1557 }
1558 if (options.profile !== undefined) {
1559 child.useProfile(options.profile);
1560 }
1561 return { id: 'agent-0', agent: child };
1562 },
1563 ),
1564 } as unknown as Session;
1565}
1566
1567function contextProfile(): ResolvedAgentProfile {
1568 return {

Callers 1

Calls 4

useProfileMethod · 0.80
setMethod · 0.65
withCwdMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected