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

Function readViaLegacyAssembly

packages/server/src/routes/snapshot.ts:132–176  ·  view source on GitHub ↗
(ix: IInstantiationService, sid: string)

Source from the content-addressed store, hash-verified

130}
131
132async function readViaLegacyAssembly(ix: IInstantiationService, sid: string) {
133 return ix.invokeFunction(async (a) => {
134 const broadcast = a.get(IWSBroadcastService);
135 const sessionService = a.get(ISessionService);
136 const messageService = a.get(IMessageService);
137 const promptService = a.get(IPromptService);
138 const approvals = a.get(IApprovalService) as ApprovalService;
139 const questions = a.get(IQuestionService) as QuestionService;
140
141 let snapState = await broadcast.getSnapshotState(sid);
142 let session: Session | undefined;
143 let items: Message[] = [];
144 let hasMore = false;
145
146 for (let attempt = 0; attempt < MAX_ASSEMBLY_ATTEMPTS; attempt++) {
147 session = await sessionService.get(sid);
148 const page = await messageService.list(sid, {
149 page_size: SNAPSHOT_MESSAGE_PAGE_SIZE,
150 });
151 items = [...page.items].reverse();
152 hasMore = page.has_more;
153
154 const post = await broadcast.getSnapshotState(sid);
155 const stable = post.seq === snapState.seq && post.epoch === snapState.epoch;
156 snapState = post;
157 if (stable) break;
158 }
159
160 const currentPromptId = promptService.getCurrentPromptId(sid);
161 const inFlightTurn = snapState.inFlightTurn;
162 if (inFlightTurn !== null && currentPromptId !== undefined) {
163 inFlightTurn.current_prompt_id = currentPromptId;
164 }
165
166 return {
167 as_of_seq: snapState.seq,
168 epoch: snapState.epoch,
169 session: session!,
170 messages: { items, has_more: hasMore },
171 in_flight_turn: inFlightTurn,
172 pending_approvals: approvals.listPending(sid),
173 pending_questions: questions.listPending(sid),
174 };
175 });
176}

Callers 1

registerSnapshotRoutesFunction · 0.85

Calls 6

invokeFunctionMethod · 0.65
getMethod · 0.65
getSnapshotStateMethod · 0.65
listMethod · 0.65
getCurrentPromptIdMethod · 0.65
listPendingMethod · 0.65

Tested by

no test coverage detected