codex@macbookpro
·
2026-03-27
delivery-pseudocode.ts
1import type { ArtifactManifest, ArtifactRef, DeliveryPlan, ExecutionResult, UploadReceipt } from "./types";
2
3 export function materializeArtifacts(results: ExecutionResult[]): ArtifactRef[] {
4 // pseudo:
5 // - choose summary.md / payload.ext / manifest.json
6 // - write files to artifact store
7 // - return refs with artifactId/localPath/mimeType
8 return [];
9 }
10
11 export function buildManifest(results: ExecutionResult[], refs: ArtifactRef[]): ArtifactManifest {
12 return {
13 manifestId: "mf_TODO",
14 traceId: "trace_TODO",
15 roundId: null,
16 entries: results.map(r => ({
17 instructionId: r.instructionId,
18 ok: r.ok,
19 summary: r.summary,
20 artifactIds: (r.artifactRefs ?? []).map(a => a.artifactId)
21 }))
22 };
23 }
24
25 export function renderIndexText(results: ExecutionResult[], manifest: ArtifactManifest): string {
26 const lines = ["[BAA 结果索引]"];
27 for (const r of results) {
28 lines.push(`- instruction_id: ${r.instructionId}`);
29 lines.push(`- 结果: ${r.ok ? "成功" : "失败"}`);
30 lines.push(`- 摘要: ${r.summary}`);
31 }
32 lines.push(`- manifest: ${manifest.manifestId}.json`);
33 return lines.join("
34");
35 }
36
37 export function buildDeliveryPlan(input: {
38 target: string;
39 conversationId: string | null;
40 traceId: string;
41 uploadRefs: ArtifactRef[];
42 indexText: string;
43 }): DeliveryPlan {
44 return {
45 planId: "plan_TODO",
46 traceId: input.traceId,
47 conversationId: input.conversationId,
48 target: input.target,
49 uploads: input.uploadRefs
50 .filter(r => r.localPath)
51 .map(r => ({
52 artifactId: r.artifactId,
53 filename: r.filename,
54 mimeType: r.mimeType,
55 localPath: r.localPath!
56 })),
57 messageText: input.indexText,
58 autoSend: true
59 };
60 }
61
62 export function shouldSendIndex(receipts: UploadReceipt[]): boolean {
63 return receipts.every(r => r.ok);
64 }