feat: integrate automatic game resource delivery

This commit is contained in:
2026-09-06 09:50:49 +08:00
parent f721966f3c
commit 4df4bc9624
20 changed files with 1667 additions and 191 deletions

View File

@@ -104,6 +104,30 @@ function capabilityBillingLabel(billing: CapabilityToolDetails['billing']): stri
}
}
function gameResourceProgressLabel(details: CapabilityToolDetails): string | null {
if (details.plugin_id !== 'makelore.game-resource' || details.operation !== 'generate'
|| !details.data || typeof details.data !== 'object' || Array.isArray(details.data)) return null;
const data = details.data as Record<string, unknown>;
const phase = typeof data.phase === 'string' ? data.phase : null;
const deliveryStatus = typeof data.deliveryStatus === 'string' ? data.deliveryStatus : null;
const providerStatus = typeof data.providerStatus === 'string' ? data.providerStatus : null;
const outputCount = Number.isSafeInteger(data.outputCount) ? data.outputCount as number : 0;
if (phase === 'saved' || deliveryStatus === 'saved') {
return `游戏资源 · 已保存 ${outputCount} 个文件`;
}
if (phase === 'saving' || deliveryStatus === 'saving') return '游戏资源 · 正在保存到项目';
if (deliveryStatus === 'delivery_failed') return '游戏资源 · 自动保存失败,等待重试';
if (phase === 'submitted') return '游戏资源 · 已提交';
if (phase === 'generating' || ['reserved', 'accepted', 'running'].includes(providerStatus ?? '')) {
return '游戏资源 · 正在生成';
}
if (providerStatus === 'pending_review') return '游戏资源 · 账单待审核';
if (providerStatus === 'submission_unknown') return '游戏资源 · 提交状态待确认';
if (providerStatus === 'cancelled') return '游戏资源 · 已取消';
if (providerStatus === 'failed') return '游戏资源 · 生成失败';
return null;
}
type ProcessItem =
| { kind: 'thinking'; id: string; block: ThinkingBlock }
| { kind: 'assistant-commentary'; id: string; node: ConversationMessageNode; blocks: ConversationContentBlock[] }
@@ -618,9 +642,12 @@ const ToolDetails = memo(function ToolDetails({ details }: { details: KnownToolD
);
}
if (details.schema === 'makelore-capability.v1') {
const gameResourceProgress = gameResourceProgressLabel(details);
return (
<div className="rounded-xl bg-foreground/[0.035] p-3 text-xs">
<p className="font-semibold"> · {details.operation}</p>
<p className="font-semibold">
{gameResourceProgress ?? `插件能力 · ${details.operation}`}
</p>
<p className="mt-1 text-muted-foreground">
{details.success ? '成功' : details.error ?? '请求失败'} · HTTP {details.status}
</p>
@@ -856,6 +883,8 @@ function toolDetailsProgress(details: KnownToolDetails | undefined): string | nu
return `已启用 ${selectedSkills.length} 项技能 · ${details.commands.length} 条命令`;
}
if (details.schema === 'makelore-capability.v1') {
const gameResourceProgress = gameResourceProgressLabel(details);
if (gameResourceProgress) return gameResourceProgress;
return details.success
? `${details.operation} · 成功`
: `${details.operation} · ${details.error ?? '请求失败'}`;
@@ -879,6 +908,10 @@ function toolDetailsProgress(details: KnownToolDetails | undefined): string | nu
}
function toolProgressPreview(node: ConversationToolNode): string {
if (node.details?.schema === 'makelore-capability.v1') {
const gameResourceProgress = gameResourceProgressLabel(node.details);
if (gameResourceProgress) return gameResourceProgress;
}
for (let index = 0; index < node.output.length; index += 1) {
const block = node.output[index];
if (!block) continue;