feat: implement PI-090 product tools

This commit is contained in:
2026-08-23 15:14:50 +08:00
parent 77cdee7e73
commit 13ab383e53
32 changed files with 2035 additions and 49 deletions

View File

@@ -12,6 +12,7 @@ import type {
PiImageProjectionInput,
PiProjectedAttachment,
} from './event-projector';
import { isProductToolName, productToolDetailsOfResult } from '../product-tool-protocol';
import { subagentDetailsOfResult } from '../subagent-protocol';
export interface PiSessionSnapshotInput {
@@ -213,24 +214,29 @@ 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}`;
const subagentDetails = subagentDetailsOfResult(message);
const details = subagentDetails ?? productToolDetailsOfResult(message);
if (details) tool.details = details;
if (subagentDetails) {
const id = `subagent:${subagentDetails.dispatchId}`;
if (!subagentIds.has(id)) {
subagentIds.add(id);
nodes.push({
kind: 'subagent',
id,
runId: input.snapshot.run.runId ?? `session:${entry.id}`,
details,
details: subagentDetails,
});
}
} else if (tool.toolName === 'subagent' && message.details !== undefined) {
} else if ((tool.toolName === 'subagent' || isProductToolName(tool.toolName))
&& message.details !== undefined
&& !details) {
tool.output = [{
kind: 'text',
id: `${tool.id}:output:unavailable`,
text: 'Subagent details are unavailable for this version.',
text: tool.toolName === 'subagent'
? 'Subagent details are unavailable for this version.'
: 'Tool details are unavailable for this version.',
status: 'complete',
}];
}