// Step 1: AI generates a draft (autonomyLevel: supervised)
const draft = await pk.file(aiDraftBuffer, {
entity: { id: "app:ai-writer", role: "organization" },
action: {
type: "create",
extensions: {
"ext:ai@1.0.0": {
provider: "openai",
model: "gpt-4o",
autonomyLevel: "supervised", // Human review required
},
},
},
});
// Step 2: Human reviews and approves — records the approval
const approval = await pk.file(
Buffer.from(JSON.stringify({ approved: true, notes: "Good. Publish it." })),
{
entity: { id: "user:editor", role: "human", name: "Editor" },
action: {
type: "verify",
inputCids: [draft.cid], // References the draft being approved
extensions: {
"ext:authorization@1.0.0": {
action: "approve",
approvedCid: draft.cid,
approvedAt: new Date().toISOString(),
approvedBy: "user:editor",
},
},
},
resourceType: "text",
}
);
// Step 3: Publish — references both draft and approval
const published = await pk.file(finalBuffer, {
entity: { id: "app:publishing-system", role: "organization" },
action: {
type: "transform",
inputCids: [draft.cid, approval.cid], // Both draft + approval are inputs
},
resourceType: "text",
});
// Graph: ai-generates-draft → editor-approves → publishing-system-publishes