MCPcopy Create free account
hub / github.com/tiann/hapi / kimiLoop

Function kimiLoop

cli/src/kimi/loop.ts:24–64  ·  view source on GitHub ↗
(opts: KimiLoopOptions)

Source from the content-addressed store, hash-verified

22}
23
24export async function kimiLoop(opts: KimiLoopOptions): Promise<void> {
25 const logPath = logger.getLogPath();
26 const startedBy = opts.startedBy ?? 'terminal';
27 const startingMode = opts.startingMode ?? 'local';
28
29 const session = new KimiSession({
30 api: opts.api,
31 client: opts.session,
32 path: opts.path,
33 sessionId: opts.resumeSessionId ?? null,
34 logPath,
35 messageQueue: opts.messageQueue,
36 onModeChange: opts.onModeChange,
37 mode: startingMode,
38 startedBy,
39 startingMode,
40 permissionMode: opts.permissionMode ?? 'default'
41 });
42
43 if (opts.resumeSessionId) {
44 session.onSessionFound(opts.resumeSessionId);
45 }
46
47 const getCurrentModel = (): string | undefined => {
48 const sessionModel = session.getModel();
49 return sessionModel != null ? sessionModel : opts.model;
50 };
51
52 await runLocalRemoteSession({
53 session,
54 startingMode: opts.startingMode,
55 logTag: 'kimi-loop',
56 runLocal: (instance) => kimiLocalLauncher(instance, {
57 model: getCurrentModel()
58 }),
59 runRemote: (instance) => kimiRemoteLauncher(instance, {
60 model: getCurrentModel()
61 }),
62 onSessionReady: opts.onSessionReady
63 });
64}

Callers 1

runKimiFunction · 0.90

Calls 5

runLocalRemoteSessionFunction · 0.90
kimiLocalLauncherFunction · 0.90
kimiRemoteLauncherFunction · 0.90
getLogPathMethod · 0.80
getCurrentModelFunction · 0.70

Tested by

no test coverage detected