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

Method getShellRunUpdate

packages/runtime/src/session-manager.ts:1349–1396  ·  view source on GitHub ↗
(sessionId: string, ref: string)

Source from the content-addressed store, hash-verified

1347 }
1348
1349 async getShellRunUpdate(sessionId: string, ref: string): Promise<ShellRunUpdate | null> {
1350 const shellRuns = this.deps.shellRuns;
1351 if (!shellRuns) return null;
1352 const own = await shellRuns.getSessionUpdate(sessionId, ref);
1353 if (own) return own;
1354
1355 const messages = await this.readShellRunProjectionMessages(sessionId);
1356 if (!messages) return null;
1357 const bashToolCalls = shellRunBashToolCallIds(messages);
1358 let candidate:
1359 | {
1360 turnId: string;
1361 toolUseId: string;
1362 result: ShellRunUpdate['result'];
1363 }
1364 | undefined;
1365 for (const message of messages) {
1366 if (
1367 message.type === 'tool_result' &&
1368 bashToolCalls.has(message.toolUseId) &&
1369 message.content.kind === 'shell_run' &&
1370 message.content.ref === ref &&
1371 isActiveShellRunStatus(message.content.status)
1372 ) {
1373 const { operation: _operation, ...result } = message.content;
1374 candidate = { turnId: message.turnId, toolUseId: message.toolUseId, result };
1375 }
1376 }
1377 if (!candidate) return null;
1378
1379 const inheritedFrom = await this.deps.store.readHeader(sessionId);
1380 const parentSessionId = inheritedFrom.revisionParentSessionId ?? inheritedFrom.parentSessionId;
1381 if (!parentSessionId) return null;
1382 const owner = await this.resolveShellRunOwner(parentSessionId, ref);
1383 return {
1384 sessionId,
1385 ownership: owner
1386 ? {
1387 kind: 'source_owned',
1388 sourceSessionId: parentSessionId,
1389 ownerSessionId: owner.sessionId,
1390 }
1391 : { kind: 'source_unavailable', sourceSessionId: parentSessionId },
1392 sourceTurnId: candidate.turnId,
1393 sourceToolCallId: candidate.toolUseId,
1394 result: owner?.result ?? candidate.result,
1395 };
1396 }
1397
1398 async recoverInterruptedSessions(): Promise<string[]> {
1399 return this.recoverInterruptedSessionsWithPolicy({ kind: 'best_effort' });

Callers

nothing calls this directly

Calls 7

resolveShellRunOwnerMethod · 0.95
isActiveShellRunStatusFunction · 0.90
shellRunBashToolCallIdsFunction · 0.85
getSessionUpdateMethod · 0.80
hasMethod · 0.65
readHeaderMethod · 0.65

Tested by

no test coverage detected