feat: surface codex reasoning summaries
This commit is contained in:
@@ -698,6 +698,65 @@ function extractToolActivitySnapshot(item, lifecycleStatus = "running") {
|
||||
return null;
|
||||
}
|
||||
|
||||
function cleanPlanStepText(text) {
|
||||
return safeProgressText(text, 220)
|
||||
.replace(/^\s*(?:[-*•]|\d+[.)]|[☐✓✔]|\[[ xX✓]\])\s*/u, "")
|
||||
.trim();
|
||||
}
|
||||
|
||||
function extractPlanStepsFromItem(item) {
|
||||
if (!item || typeof item !== "object" || item.type !== "plan") {
|
||||
return [];
|
||||
}
|
||||
const rawSteps = asArray(item.steps).length > 0
|
||||
? asArray(item.steps).map((step) => extractProgressText(step))
|
||||
: String(item.text ?? "")
|
||||
.split(/\r?\n/)
|
||||
.map((line) => line.trim());
|
||||
return rawSteps
|
||||
.map(cleanPlanStepText)
|
||||
.filter(Boolean)
|
||||
.slice(0, 10)
|
||||
.map((text, index) => ({
|
||||
id: `plan-item-${index + 1}`,
|
||||
text,
|
||||
status: "pending",
|
||||
}));
|
||||
}
|
||||
|
||||
function extractReasoningSummaryText(summary) {
|
||||
const values = asArray(summary).length > 0 ? asArray(summary) : [summary];
|
||||
return safeProgressText(
|
||||
values
|
||||
.map((item) => {
|
||||
if (typeof item === "string") {
|
||||
return item;
|
||||
}
|
||||
if (item && typeof item === "object") {
|
||||
return item.text ?? item.summary ?? "";
|
||||
}
|
||||
return "";
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(" / "),
|
||||
280,
|
||||
);
|
||||
}
|
||||
|
||||
function extractReasoningSummarySnapshot(item, lifecycleStatus = "running") {
|
||||
if (!item || typeof item !== "object" || item.type !== "reasoning") {
|
||||
return null;
|
||||
}
|
||||
const summary = extractReasoningSummaryText(item.summary);
|
||||
if (!summary) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
status: safeProgressText(item.status, 40) || lifecycleStatus,
|
||||
summary,
|
||||
};
|
||||
}
|
||||
|
||||
function extractSubAgentSource(value) {
|
||||
if (!value || typeof value !== "object") {
|
||||
return undefined;
|
||||
@@ -1249,6 +1308,7 @@ function createProgressCollector() {
|
||||
let compaction;
|
||||
let threadCollaboration;
|
||||
const toolActivities = [];
|
||||
let reasoningSummary;
|
||||
let accountStatus;
|
||||
let modelVerification;
|
||||
|
||||
@@ -1390,6 +1450,10 @@ function createProgressCollector() {
|
||||
for (const artifact of extractArtifactsFromItem(message.params?.item, artifacts.length)) {
|
||||
upsertArtifact(artifact);
|
||||
}
|
||||
const itemPlanSteps = extractPlanStepsFromItem(item);
|
||||
if (itemPlanSteps.length > 0) {
|
||||
steps.splice(0, steps.length, ...itemPlanSteps);
|
||||
}
|
||||
const nextCollaboration = extractThreadCollaborationSnapshot(item);
|
||||
if (nextCollaboration) {
|
||||
threadCollaboration = nextCollaboration;
|
||||
@@ -1397,6 +1461,13 @@ function createProgressCollector() {
|
||||
upsertToolActivity(
|
||||
extractToolActivitySnapshot(item, message.method === "item/completed" ? "completed" : "running"),
|
||||
);
|
||||
const nextReasoningSummary = extractReasoningSummarySnapshot(
|
||||
item,
|
||||
message.method === "item/completed" ? "completed" : "running",
|
||||
);
|
||||
if (nextReasoningSummary) {
|
||||
reasoningSummary = nextReasoningSummary;
|
||||
}
|
||||
if (item?.type === "contextCompaction") {
|
||||
compaction = {
|
||||
status: "completed",
|
||||
@@ -1703,6 +1774,9 @@ function createProgressCollector() {
|
||||
if (toolActivities.length > 0) {
|
||||
result.toolActivities = toolActivities.map((item) => ({ ...item }));
|
||||
}
|
||||
if (reasoningSummary) {
|
||||
result.reasoningSummary = { ...reasoningSummary };
|
||||
}
|
||||
if (accountStatus) {
|
||||
result.accountStatus = { ...accountStatus };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user