feat: add Pi subagent scheduler and child runtime
This commit is contained in:
@@ -12,6 +12,7 @@ import type {
|
||||
PiImageProjectionInput,
|
||||
PiProjectedAttachment,
|
||||
} from './event-projector';
|
||||
import { subagentDetailsOfResult } from '../subagent-protocol';
|
||||
|
||||
export interface PiSessionSnapshotInput {
|
||||
snapshot: ConversationSnapshot;
|
||||
@@ -184,6 +185,7 @@ async function projectEntries(
|
||||
): Promise<ConversationNode[]> {
|
||||
const nodes: ConversationNode[] = [];
|
||||
const tools = new Map<string, ConversationToolNode>();
|
||||
const subagentIds = new Set<string>();
|
||||
for (const entry of path) {
|
||||
if (entry.type === 'compaction') {
|
||||
nodes.push({
|
||||
@@ -211,6 +213,27 @@ async function projectEntries(
|
||||
'output',
|
||||
);
|
||||
tool.status = message.isError === true ? 'error' : 'complete';
|
||||
const details = subagentDetailsOfResult(message);
|
||||
if (details) {
|
||||
tool.details = details;
|
||||
const id = `subagent:${details.dispatchId}`;
|
||||
if (!subagentIds.has(id)) {
|
||||
subagentIds.add(id);
|
||||
nodes.push({
|
||||
kind: 'subagent',
|
||||
id,
|
||||
runId: input.snapshot.run.runId ?? `session:${entry.id}`,
|
||||
details,
|
||||
});
|
||||
}
|
||||
} else if (tool.toolName === 'subagent' && message.details !== undefined) {
|
||||
tool.output = [{
|
||||
kind: 'text',
|
||||
id: `${tool.id}:output:unavailable`,
|
||||
text: 'Subagent details are unavailable for this version.',
|
||||
status: 'complete',
|
||||
}];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (message.role !== 'user' && message.role !== 'assistant') continue;
|
||||
|
||||
Reference in New Issue
Block a user