Feat/design agent simple #305

Merged
lhk229 merged 66 commits from feat/design_agent_simple into master 2026-09-09 16:34:50 +08:00
Showing only changes of commit f7b15f124f - Show all commits
@@ -182,9 +182,11 @@ function asRecord(value: unknown): Record<string, unknown> | null {
: null;
}
function resultQuestion(result: PlanningTurnResultV2 | null) {
const payload = asRecord(result?.payload);
const question = asRecord(payload?.question);
function questionFromPayload(payloadValue: unknown) {
const payload = asRecord(payloadValue);
// Turn results wrap the question in `payload.question`; persisted
// conversation messages store the question object directly in `payload`.
const question = asRecord(payload?.question) ?? payload;
if (!question) {
return null;
}
@@ -218,6 +220,10 @@ function resultQuestion(result: PlanningTurnResultV2 | null) {
} satisfies PlanningQuestionV2;
}
function resultQuestion(result: PlanningTurnResultV2 | null) {
return questionFromPayload(result?.payload);
}
export function planningResultText(result: PlanningTurnResultV2 | null) {
const text = result?.payload?.text;
return typeof text === 'string' ? text : '';
@@ -274,11 +280,7 @@ function messageDisplayText(message: PlanningMessageV2) {
return payload.text;
}
if (message.kind === 'question') {
const question = resultQuestion({
schemaVersion: 'planning-turn-result.v2',
kind: 'question',
payload: payload ?? {},
});
const question = questionFromPayload(payload);
return question ? questionDisplayText(question) : '';
}
if (message.kind === 'artifact') {