feat(short-drama-agent-front): 接入联合修订与图片费用审计
This commit is contained in:
1 parent
87427d9d43
commit
f6edc4eb70
52 files changed
+5060
-516
No files matched your search
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
import { imageAuthorizationsFixture } from './billing'
|
||||
import type { ImageChargeRequest, ImageAuthorizationList } from '../../src/features/image-authorization/types'
|
||||
/**
|
||||
* 仅供Mock的unknown请求及同一精确计划的有限许可。
|
||||
* @param projectId 隔离项目
|
||||
* @returns 原预留与unknown始终保留的费用投影
|
||||
*/
|
||||
export function additionalImageFixture(projectId = 'billing-project'): ImageAuthorizationList {
|
||||
const list = imageAuthorizationsFixture()
|
||||
const grant = list.authorizations[0]!
|
||||
const parent: ImageChargeRequest = {
|
||||
id: 'original-image-request',
|
||||
status: 'unknown',
|
||||
input: {
|
||||
projectId,
|
||||
authorizationId: grant.id,
|
||||
candidateId: 'original-image',
|
||||
targetId: 'audit-shot',
|
||||
scope: 'keyframe',
|
||||
provider: 'openai-image',
|
||||
model: 'gpt-image-2.5-flare',
|
||||
planFingerprint: 'b'.repeat(64),
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
reservedMicros: grant.input.perRequestMicros,
|
||||
request: { prompt: '仅供Mock的原精确计划' }
|
||||
},
|
||||
output: {
|
||||
usageCostMicros: null,
|
||||
actualBilledMicros: null,
|
||||
error: { failureType: 'timeout_unknown', transportMode: 'proxy', causeCode: 'UND_ERR_CONNECT_TIMEOUT' }
|
||||
}
|
||||
}
|
||||
grant.usedRequests++
|
||||
grant.remainingRequests--
|
||||
grant.accountedMicros += parent.input.reservedMicros
|
||||
grant.remainingMicros -= parent.input.reservedMicros
|
||||
list.requests.push(parent)
|
||||
list.billingBlocked = true
|
||||
list.originalBlockingRequestIds = [parent.id]
|
||||
list.blockingRequestIds = [parent.id]
|
||||
list.additionalAuthorizations = [
|
||||
{
|
||||
id: 'additional-permit',
|
||||
status: 'approved',
|
||||
input: {
|
||||
mode: 'additional',
|
||||
idempotencyKey: 'test-additional',
|
||||
parentRequestId: parent.id,
|
||||
maxRequests: 2,
|
||||
acknowledgeUnknownPriorBilling: true,
|
||||
approvedBy: '测试人工批准人',
|
||||
approvalNote: '仅供Mock的有限风险确认',
|
||||
parentInputFingerprint: 'd'.repeat(64)
|
||||
},
|
||||
usedRequests: 0,
|
||||
remainingRequests: 2
|
||||
}
|
||||
]
|
||||
return list
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
import type { BillingFacts } from '../../src/features/billing-audit/types'
|
||||
import type { ImageBillingAuditView } from '../../src/features/image-authorization/billing-audit.types'
|
||||
/**
|
||||
* 仅供Mock的原图片请求视图,不代表真实Provider材料。
|
||||
* @param projectId 隔离项目
|
||||
* @param requestId 隔离原请求
|
||||
* @returns 带完整原版本和空历史的审计视图
|
||||
*/
|
||||
export function imageAuditFixture(projectId = 'audit-project', requestId = 'unknown-image'): ImageBillingAuditView {
|
||||
return {
|
||||
projectId,
|
||||
requestId,
|
||||
identity: {
|
||||
projectId,
|
||||
requestId,
|
||||
authorizationId: 'grant',
|
||||
scope: 'keyframe',
|
||||
targetId: 'audit-shot',
|
||||
candidateId: 'unknown-candidate',
|
||||
provider: 'openai-image',
|
||||
model: 'gpt-image-2.5-flare',
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
planFingerprint: 'b'.repeat(64),
|
||||
requestFingerprint: 'd'.repeat(64)
|
||||
},
|
||||
taskFingerprint: 'a'.repeat(64),
|
||||
evidenceSetFingerprint: 'e'.repeat(64),
|
||||
reviewFingerprint: 'f'.repeat(64),
|
||||
originalRequestStatus: 'unknown',
|
||||
reservedMicros: 1_000_000,
|
||||
originalUsageCostMicros: null,
|
||||
originalActualBilledMicros: null,
|
||||
originalProviderRequestId: null,
|
||||
hasOriginalReceipt: false,
|
||||
originalBillingBlocked: true,
|
||||
billingBlocked: true,
|
||||
released: false,
|
||||
status: 'unreviewed',
|
||||
reviewId: null,
|
||||
reviewedAmountMicros: null,
|
||||
releaseIssues: ['缺少当前独立复核的证据'],
|
||||
history: { evidence: [], reviews: [] }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 只用于隔离验收的合格材料,不能登记到正式项目。
|
||||
* @returns 明确标为测试的Provider原件声明
|
||||
*/
|
||||
export function imageAuditFacts(): BillingFacts {
|
||||
return {
|
||||
correlation: 'unique',
|
||||
providerRequestId: 'test-provider-request',
|
||||
artifacts: [
|
||||
{
|
||||
id: 'exec',
|
||||
kind: 'provider-execution',
|
||||
recordId: 'test-provider-execution',
|
||||
sha256: '1'.repeat(64),
|
||||
reference: '仅供Mock验收的执行原件'
|
||||
},
|
||||
{
|
||||
id: 'bill',
|
||||
kind: 'provider-billing',
|
||||
recordId: 'test-provider-bill',
|
||||
sha256: '2'.repeat(64),
|
||||
reference: '仅供Mock验收的账单原件'
|
||||
}
|
||||
],
|
||||
execution: { outcome: 'failed', evidenceIds: ['exec'] },
|
||||
billing: { finding: 'charged', amount: 0.000001, currency: 'USD', evidenceIds: ['bill'] }
|
||||
}
|
||||
}
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
import { directionsResult, visualStatesResult, designedShot } from '../../src/features/storyboard/testing/fixtures'
|
||||
import { draftFromFormal } from '../../src/features/storyboard/derived-review'
|
||||
import { preparationFixture } from '../features/storyboard-preparation/fixtures'
|
||||
import type { KeyframeSpec } from '../../src/features/production/types'
|
||||
import type { SavedKeyframeDraft } from '../../src/features/storyboard/derived-review.types'
|
||||
/**
|
||||
* 当前正式数据和已保存草案的隔离投影,不用于正式项目。
|
||||
* @param projectId 隔离项目
|
||||
* @returns 可用于Vitest/Chrome的完整原版本与有限差异
|
||||
*/
|
||||
export function jointReviewFixture(projectId = 'joint-review-project') {
|
||||
const shot = designedShot(),
|
||||
approval = preparationFixture(projectId),
|
||||
directions = directionsResult(projectId),
|
||||
visuals = visualStatesResult(projectId, 1, true)
|
||||
const keyframe: KeyframeSpec = {
|
||||
projectId,
|
||||
shotId: shot.shotId,
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: 1,
|
||||
prompt: '隔离正式开拍输入',
|
||||
formalSourceFingerprint: 'e'.repeat(64),
|
||||
references: []
|
||||
}
|
||||
const formal = draftFromFormal(shot, keyframe, approval.record.shotFingerprint)
|
||||
const draft = structuredClone(formal)
|
||||
draft.direction.composition = '仅用于Mock的构图调整'
|
||||
draft.direction.visualIntent = '保留正式动作的开拍意图'
|
||||
draft.visualState.subjects[0]!.pose = '仅用于Mock的0秒姿态'
|
||||
draft.visualState.continuityNote =
|
||||
'【输入事实】原主体保持开拍姿态。【规划末态】后续镜头规划,尚未执行。【连续要求】保持原观察轴。【视频末态】未知,尚无真实视频末态证据。'
|
||||
const saved: SavedKeyframeDraft = {
|
||||
shotId: shot.shotId,
|
||||
revision: 7,
|
||||
updatedAt: '2026-11-16T01:00:00Z',
|
||||
status: 'current',
|
||||
staleReason: null,
|
||||
draft,
|
||||
providerInput: { provider: 'openai-image', generationOptions: { quality: 'auto' } },
|
||||
expectedCurrentFormalSourceFingerprint: keyframe.formalSourceFingerprint!
|
||||
}
|
||||
return {
|
||||
shot,
|
||||
shots: [shot, { ...designedShot('shot-db-1-2'), beatNo: 2 }],
|
||||
approval,
|
||||
directions,
|
||||
visuals,
|
||||
keyframe,
|
||||
formal,
|
||||
saved
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user