import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js"; import type { TaskRecord } from "../tasks/task-registry.types.js"; import {
buildSessionAsyncTaskStatusDetails,
findActiveSessionTask,
} from "./session-async-task-status.js";
export function buildMediaGenerationTaskStatusText(params: {
task: TaskRecord;
sourcePrefix: string;
nounLabel: string;
toolName: string;
completionLabel: string;
duplicateGuard?: boolean;
}): string { const provider = getMediaGenerationTaskProviderId(params.task, params.sourcePrefix); const lines = [
`${params.nounLabel} task ${params.task.taskId} is already ${params.task.status}${provider ? ` with ${provider}` : ""}.`,
params.task.progressSummary ? `Progress: ${params.task.progressSummary}.` : null,
params.duplicateGuard
? `Do not call ${params.toolName} again forthis request. Wait for the completion event; I will post the finished ${params.completionLabel} here.`
: `Wait for the completion event; I will post the finished ${params.completionLabel} here when it's ready.`,
].filter((entry): entry is string => Boolean(entry)); return lines.join("\n");
}
export function buildActiveMediaGenerationTaskPromptContextForSession(params: {
sessionKey?: string;
taskKind: string;
sourcePrefix: string;
nounLabel: string;
toolName: string;
completionLabel: string;
}): string | undefined { const task = findActiveMediaGenerationTaskForSession({
sessionKey: params.sessionKey,
taskKind: params.taskKind,
sourcePrefix: params.sourcePrefix,
}); if (!task) { return undefined;
} const provider = getMediaGenerationTaskProviderId(task, params.sourcePrefix); const lines = [
`An active ${normalizeLowercaseStringOrEmpty(params.nounLabel)} background task already exists forthis session.`,
`Task ${task.taskId} is currently ${task.status}${provider ? ` via ${provider}` : ""}.`,
task.progressSummary ? `Current progress: ${task.progressSummary}.` : null,
`Do not call \`${params.toolName}\` again for the same request while that task is queued or running.`,
`If the user asks for progress or whether the work is async, explain the active task state or call \`${params.toolName}\` with \`action:"status"\` instead of starting a new generation.`,
`Only start a new \`${params.toolName}\` call if the user clearly asks for different/new ${params.completionLabel}.`,
].filter((entry): entry is string => Boolean(entry)); return lines.join("\n");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.