MCPcopy Create free account
hub / github.com/apache/maka / listShellRunUpdates

Method listShellRunUpdates

packages/runtime/src/session-manager.ts:1288–1347  ·  view source on GitHub ↗
(sessionId: string)

Source from the content-addressed store, hash-verified

1286 }
1287
1288 async listShellRunUpdates(sessionId: string): Promise<ShellRunUpdate[]> {
1289 const shellRuns = this.deps.shellRuns;
1290 if (!shellRuns) return [];
1291
1292 const ownUpdates = await shellRuns.listSessionUpdates(sessionId);
1293 const ownToolCalls = new Set(ownUpdates.map((update) => update.sourceToolCallId));
1294 const messages = await this.readShellRunProjectionMessages(sessionId);
1295 if (!messages) return ownUpdates;
1296 const bashToolCalls = shellRunBashToolCallIds(messages);
1297 const inherited = new Map<
1298 string,
1299 {
1300 ref: string;
1301 turnId: string;
1302 toolUseId: string;
1303 result: ShellRunUpdate['result'];
1304 }
1305 >();
1306 for (const message of messages) {
1307 if (
1308 message.type === 'tool_result' &&
1309 bashToolCalls.has(message.toolUseId) &&
1310 !ownToolCalls.has(message.toolUseId) &&
1311 message.content.kind === 'shell_run' &&
1312 isActiveShellRunStatus(message.content.status)
1313 ) {
1314 const { operation: _operation, ...result } = message.content;
1315 inherited.set(message.toolUseId, {
1316 ref: message.content.ref,
1317 turnId: message.turnId,
1318 toolUseId: message.toolUseId,
1319 result,
1320 });
1321 }
1322 }
1323 if (inherited.size === 0) return ownUpdates;
1324
1325 const inheritedFrom = await this.deps.store.readHeader(sessionId);
1326 const parentSessionId = inheritedFrom.revisionParentSessionId ?? inheritedFrom.parentSessionId;
1327 if (!parentSessionId) return ownUpdates;
1328 const inheritedUpdates = await Promise.all(
1329 [...inherited.values()].map(async (candidate) => {
1330 const owner = await this.resolveShellRunOwner(parentSessionId, candidate.ref);
1331 return {
1332 sessionId,
1333 ownership: owner
1334 ? {
1335 kind: 'source_owned',
1336 sourceSessionId: parentSessionId,
1337 ownerSessionId: owner.sessionId,
1338 }
1339 : { kind: 'source_unavailable', sourceSessionId: parentSessionId },
1340 sourceTurnId: candidate.turnId,
1341 sourceToolCallId: candidate.toolUseId,
1342 result: owner?.result ?? candidate.result,
1343 } satisfies ShellRunUpdate;
1344 }),
1345 );

Callers

nothing calls this directly

Calls 9

resolveShellRunOwnerMethod · 0.95
isActiveShellRunStatusFunction · 0.90
shellRunBashToolCallIdsFunction · 0.85
listSessionUpdatesMethod · 0.80
valuesMethod · 0.80
hasMethod · 0.65
setMethod · 0.65
readHeaderMethod · 0.65

Tested by

no test coverage detected