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

Function projectSubagentToolResult

packages/runtime/src/subagent-tools.ts:335–360  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

333}
334
335function projectSubagentToolResult(value: unknown): Omit<SubagentToolResult, 'kind'> {
336 if (!value || typeof value !== 'object' || Array.isArray(value)) {
337 throw new Error('Child agent returned an invalid result');
338 }
339 const raw = value as Record<string, unknown>;
340 const decoded = decodeCanonicalToolResultContent({
341 kind: 'subagent',
342 ...(raw.childSessionId !== undefined ? { childSessionId: raw.childSessionId } : {}),
343 ...(raw.agentId !== undefined ? { agentId: raw.agentId } : {}),
344 agentName: raw.agentName,
345 turnId: raw.turnId,
346 ...(raw.runId !== undefined ? { runId: raw.runId } : {}),
347 status: raw.status,
348 permissionMode: raw.permissionMode,
349 summary: raw.summary,
350 artifactIds: raw.artifactIds,
351 ...(raw.startedAt !== undefined ? { startedAt: raw.startedAt } : {}),
352 ...(raw.completedAt !== undefined ? { completedAt: raw.completedAt } : {}),
353 ...(raw.durationMs !== undefined ? { durationMs: raw.durationMs } : {}),
354 ...(raw.eventCount !== undefined ? { eventCount: raw.eventCount } : {}),
355 ...(raw.failureClass !== undefined ? { failureClass: raw.failureClass } : {}),
356 });
357 if (decoded.kind !== 'subagent') throw new Error('Child agent returned an invalid result');
358 const { kind: _kind, ...result } = decoded as SubagentToolResult;
359 return result;
360}
361
362function boundedChildError(error: unknown): string {
363 const message = error instanceof Error ? error.message : 'unknown error';

Callers 1

buildSubagentSpawnToolFunction · 0.85

Calls 1

Tested by

no test coverage detected