吸收数字员工产物交付状态
This commit is contained in:
@@ -2052,23 +2052,28 @@ function buildArtifacts(snapshot: QimingclawSnapshot | null): ArtifactEntry[] {
|
||||
|
||||
function artifactFromRuntimeRecord(artifact: QimingclawArtifactRecord): ArtifactEntry {
|
||||
const payload = asRecord(artifact.payload);
|
||||
const delivery = asRecord(payload?.delivery);
|
||||
const sourceTool = stringValue(delivery?.source_tool);
|
||||
const deliveryUri = stringValue(delivery?.uri);
|
||||
const deliveryFilename = stringValue(delivery?.filename);
|
||||
return {
|
||||
artifact_id: artifact.id,
|
||||
subject_id: artifact.runId ?? artifact.taskId ?? artifact.planId ?? artifact.id,
|
||||
kind: artifact.kind,
|
||||
name: artifact.name || stringValue(payload?.name ?? payload?.title) || artifactName(artifact.uri ?? '') || artifact.kind,
|
||||
uri: artifact.uri || stringValue(payload?.uri ?? payload?.url ?? payload?.path) || undefined,
|
||||
value: stringValue(payload?.value ?? payload?.summary ?? payload?.text) || artifact.uri || artifact.name || artifact.kind,
|
||||
name: artifact.name || deliveryFilename || stringValue(payload?.name ?? payload?.title) || artifactName(artifact.uri ?? deliveryUri) || artifact.kind,
|
||||
uri: artifact.uri || deliveryUri || stringValue(payload?.uri ?? payload?.url ?? payload?.path) || undefined,
|
||||
value: stringValue(payload?.value ?? payload?.summary ?? payload?.text) || artifact.uri || deliveryUri || artifact.name || deliveryFilename || artifact.kind,
|
||||
plan_id: artifact.planId ?? null,
|
||||
task_id: artifact.taskId ?? null,
|
||||
run_id: artifact.runId ?? null,
|
||||
created_at: artifact.createdAt,
|
||||
source: 'qimingclaw-runtime',
|
||||
source_type: 'artifact',
|
||||
source_label: artifactSourceLabel('artifact', artifact.id),
|
||||
source_label: sourceTool ? `File Server: ${sourceTool}` : artifactSourceLabel('artifact', artifact.id),
|
||||
sync_status: artifact.syncStatus,
|
||||
sync_error: artifact.syncError,
|
||||
payload: artifact.payload,
|
||||
...deliveryProjection(delivery),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2136,23 +2141,27 @@ function artifactFromValue(
|
||||
): ArtifactEntry {
|
||||
const record = asRecord(value);
|
||||
if (record) {
|
||||
const delivery = asRecord(record.delivery);
|
||||
const sourceTool = stringValue(delivery?.source_tool);
|
||||
const deliveryUri = stringValue(delivery?.uri);
|
||||
const uri = stringValue(record.uri ?? record.url ?? record.path ?? record.filePath ?? record.file_path ?? record.outputPath ?? record.output_path);
|
||||
const name = stringValue(record.name ?? record.title ?? record.filename) || artifactName(uri) || `产物 ${index + 1}`;
|
||||
const name = stringValue(record.name ?? record.title ?? record.filename) || stringValue(delivery?.filename) || artifactName(uri || deliveryUri) || `产物 ${index + 1}`;
|
||||
return {
|
||||
artifact_id: stringValue(record.artifact_id ?? record.id) || `artifact-${slugifyIdPart(subjectId)}-${index + 1}`,
|
||||
subject_id: stringValue(record.subject_id) || subjectId,
|
||||
kind: stringValue(record.kind ?? record.type) || 'artifact',
|
||||
name,
|
||||
uri,
|
||||
value: stringValue(record.value ?? record.summary ?? record.text) || uri,
|
||||
uri: uri || deliveryUri,
|
||||
value: stringValue(record.value ?? record.summary ?? record.text) || uri || deliveryUri,
|
||||
created_at: (stringValue(record.created_at ?? record.createdAt) || createdAt) ?? undefined,
|
||||
source: 'qimingclaw-runtime',
|
||||
source_type: stringValue(record.source_type) || sourceContext?.sourceType || 'payload',
|
||||
source_event_id: stringValue(record.source_event_id) || sourceContext?.sourceEventId || null,
|
||||
source_label: stringValue(record.source_label) || sourceContext?.sourceLabel || artifactSourceLabel('payload', subjectId),
|
||||
source_label: sourceTool ? `File Server: ${sourceTool}` : stringValue(record.source_label) || sourceContext?.sourceLabel || artifactSourceLabel('payload', subjectId),
|
||||
plan_id: stringValue(record.plan_id) || sourceContext?.planId || null,
|
||||
task_id: stringValue(record.task_id) || sourceContext?.taskId || null,
|
||||
run_id: stringValue(record.run_id) || sourceContext?.runId || null,
|
||||
...deliveryProjection(delivery),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2175,6 +2184,20 @@ function artifactFromValue(
|
||||
};
|
||||
}
|
||||
|
||||
function deliveryProjection(delivery: Record<string, unknown> | null): Record<string, unknown> {
|
||||
if (!delivery) return {};
|
||||
return {
|
||||
delivery_status: stringValue(delivery.status) || null,
|
||||
delivery_stage: stringValue(delivery.stage) || null,
|
||||
workspace_id: stringValue(delivery.workspace_id) || null,
|
||||
project_id: stringValue(delivery.project_id) || null,
|
||||
file_id: stringValue(delivery.file_id) || null,
|
||||
version: stringValue(delivery.version) || null,
|
||||
file_size: numberValue(delivery.size),
|
||||
source_tool: stringValue(delivery.source_tool) || null,
|
||||
};
|
||||
}
|
||||
|
||||
function artifactSourceLabel(sourceType: string, sourceId?: string | null): string {
|
||||
const suffix = sourceId ? ` ${sourceId}` : '';
|
||||
switch (sourceType) {
|
||||
@@ -2211,6 +2234,15 @@ function stringValue(value: unknown): string {
|
||||
return typeof value === 'string' ? value.trim() : '';
|
||||
}
|
||||
|
||||
function numberValue(value: unknown): number | null {
|
||||
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
||||
if (typeof value === 'string' && value.trim()) {
|
||||
const parsed = Number(value);
|
||||
return Number.isFinite(parsed) ? parsed : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function looksLikeUri(value: string): boolean {
|
||||
return /^(file|https?):\/\//i.test(value) || value.includes('/') || value.includes('\\');
|
||||
}
|
||||
@@ -2555,6 +2587,14 @@ function reportArtifactSources(artifacts: ArtifactEntry[]) {
|
||||
name: stringValue(artifact.name) || stringValue(artifact.uri) || stringValue(artifact.value) || '未命名产物',
|
||||
kind: stringValue(artifact.kind) || null,
|
||||
uri: stringValue(artifact.uri) || null,
|
||||
delivery_status: stringValue(artifact.delivery_status) || null,
|
||||
delivery_stage: stringValue(artifact.delivery_stage) || null,
|
||||
workspace_id: stringValue(artifact.workspace_id) || null,
|
||||
project_id: stringValue(artifact.project_id) || null,
|
||||
file_id: stringValue(artifact.file_id) || null,
|
||||
version: stringValue(artifact.version) || null,
|
||||
file_size: typeof artifact.file_size === 'number' ? artifact.file_size : null,
|
||||
source_tool: stringValue(artifact.source_tool) || null,
|
||||
source_label: stringValue(artifact.source_label) || null,
|
||||
source_type: stringValue(artifact.source_type) || null,
|
||||
source_event_id: stringValue(artifact.source_event_id) || null,
|
||||
|
||||
Reference in New Issue
Block a user