Pi and OMP share only the JSONL child-process transport while retaining provider-owned launch, RPC, runtime, session, history, and permission behavior. Removes captured fixtures in favor of typed harnesses and real-provider coverage. Closes #2006 Closes #2060
118 lines
2.8 KiB
TypeScript
118 lines
2.8 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
|
|
import { OmpSubagentIndex } from "./subagent-index.js";
|
|
|
|
describe("OMP provider subagent mapper", () => {
|
|
test("maps lifecycle and progress frames to stable provider_subagent descriptors", () => {
|
|
const index = new OmpSubagentIndex();
|
|
const parent = {};
|
|
expect(
|
|
index.handleLifecycle(parent, {
|
|
id: "child-1",
|
|
agent: "explore",
|
|
description: "Inspect files",
|
|
status: "started",
|
|
parentToolCallId: "task-1",
|
|
index: 0,
|
|
}),
|
|
).toEqual([
|
|
{
|
|
type: "provider_subagent",
|
|
provider: "omp",
|
|
event: {
|
|
type: "upsert",
|
|
id: "child-1",
|
|
title: "explore",
|
|
description: "Inspect files",
|
|
status: "running",
|
|
toolCallId: "task-1",
|
|
},
|
|
},
|
|
]);
|
|
|
|
expect(
|
|
index.handleProgress(parent, {
|
|
index: 0,
|
|
agent: "explore",
|
|
task: "Inspect files",
|
|
parentToolCallId: "task-1",
|
|
progress: {
|
|
id: "child-1",
|
|
status: "running",
|
|
resolvedModel: "openai-codex/gpt-5.5",
|
|
},
|
|
})[0],
|
|
).toMatchObject({
|
|
event: {
|
|
id: "child-1",
|
|
status: "running",
|
|
title: "explore · gpt-5.5 (openai-codex)",
|
|
},
|
|
});
|
|
|
|
expect(
|
|
index.handleProgress(parent, {
|
|
index: 0,
|
|
agent: "explore",
|
|
task: "Inspect files",
|
|
parentToolCallId: "task-1",
|
|
progress: {
|
|
id: "child-1",
|
|
status: "completed",
|
|
resolvedModel: "anthropic/claude-sonnet-5",
|
|
},
|
|
})[0],
|
|
).toMatchObject({
|
|
event: {
|
|
id: "child-1",
|
|
status: "completed",
|
|
title: "explore · claude-sonnet-5 (anthropic)",
|
|
},
|
|
});
|
|
});
|
|
|
|
test("maps child message events onto the descriptor timeline", () => {
|
|
const index = new OmpSubagentIndex();
|
|
const parent = {};
|
|
expect(
|
|
index.handleEvent(parent, {
|
|
id: "child-1",
|
|
event: {
|
|
type: "message_end",
|
|
message: {
|
|
role: "assistant",
|
|
content: [{ type: "text", text: "Child answer" }],
|
|
},
|
|
},
|
|
}),
|
|
).toEqual([
|
|
{
|
|
type: "provider_subagent",
|
|
provider: "omp",
|
|
event: {
|
|
type: "timeline",
|
|
id: "child-1",
|
|
item: {
|
|
type: "assistant_message",
|
|
text: "Child answer",
|
|
messageId: "omp-history-assistant-1",
|
|
},
|
|
},
|
|
},
|
|
]);
|
|
});
|
|
|
|
test("maps aborted lifecycle status to canceled", () => {
|
|
const index = new OmpSubagentIndex();
|
|
const parent = {};
|
|
expect(
|
|
index.handleLifecycle(parent, {
|
|
id: "child-1",
|
|
agent: "task",
|
|
status: "aborted",
|
|
index: 0,
|
|
})[0],
|
|
).toMatchObject({ event: { id: "child-1", status: "canceled" } });
|
|
});
|
|
});
|