feat: add Pi subagent scheduler and child runtime
This commit is contained in:
@@ -33,6 +33,57 @@ function baseSnapshot(): ConversationSnapshot {
|
||||
const zeroCost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 };
|
||||
|
||||
describe('Pi session projector', () => {
|
||||
it('hydrates stable subagent nodes and bounds unknown detail versions', async () => {
|
||||
const snapshot = await projectPiSessionSnapshot({
|
||||
snapshot: baseSnapshot(),
|
||||
workerGeneration: 1,
|
||||
state: { sessionId: 'session-a', isStreaming: false, isCompacting: false },
|
||||
entries: {
|
||||
leafId: 'entry-unknown-result',
|
||||
entries: [
|
||||
{
|
||||
type: 'message', id: 'entry-assistant', parentId: null,
|
||||
message: {
|
||||
role: 'assistant', stopReason: 'toolUse', usage: { input: 1, output: 1 },
|
||||
content: [
|
||||
{ type: 'toolCall', id: 'call-known', name: 'subagent', arguments: {} },
|
||||
{ type: 'toolCall', id: 'call-unknown', name: 'subagent', arguments: {} },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'message', id: 'entry-known-result', parentId: 'entry-assistant',
|
||||
message: {
|
||||
role: 'toolResult', toolCallId: 'call-known', toolName: 'subagent', content: [],
|
||||
details: {
|
||||
schema: 'subagent.v1', dispatchId: 'dispatch-a', mode: 'single',
|
||||
tasks: [{
|
||||
taskId: 'task-a', agentId: 'agent-a', toolProfile: 'coding', status: 'complete',
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'message', id: 'entry-unknown-result', parentId: 'entry-known-result',
|
||||
message: {
|
||||
role: 'toolResult', toolCallId: 'call-unknown', toolName: 'subagent', content: [],
|
||||
details: { schema: 'subagent.v9', raw: 'RAW_SESSION_SECRET' },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(snapshot.nodes).toContainEqual(expect.objectContaining({
|
||||
kind: 'subagent', id: 'subagent:dispatch-a',
|
||||
details: expect.objectContaining({ schema: 'subagent.v1' }),
|
||||
}));
|
||||
expect(JSON.stringify(snapshot)).not.toContain('RAW_SESSION_SECRET');
|
||||
expect(snapshot.nodes).toContainEqual(expect.objectContaining({
|
||||
kind: 'tool', toolCallId: 'call-unknown',
|
||||
output: [expect.objectContaining({ text: 'Subagent details are unavailable for this version.' })],
|
||||
}));
|
||||
});
|
||||
|
||||
it('hydrates only the authoritative active leaf path', async () => {
|
||||
const snapshot = await projectPiSessionSnapshot({
|
||||
snapshot: baseSnapshot(),
|
||||
|
||||
Reference in New Issue
Block a user