The Conversational Pivot Protocol (CPP) Integration Pack maps out the complete technical specification to bridge local-first depthOS vault applications with high-fidelity distributed AI intelligence nodes.
By shifting conversations from simple chronological message arrays to a state-managed Directed Semantic Graph (DSG), this pack empowers your application layers with mid-stream interruption-pivoting, retroactive branch anchoring, and parallel future timeline swaps.
export interface ChatMessage {
id: string;
sender: string;
role: 'user' | 'assistant' | 'system' | 'peer';
content: string;
timestamp: string;
signature?: string; // Cryptographic DID signature proof for sovereign verification
parentId: string | null;
status: 'completed' | 'generating' | 'interrupted';
childrenIds: string[];
}export function getActivePath(thread: ChatThread): ChatMessage[] {
if (!thread || !thread.messages || thread.messages.length === 0) return [];
const messages = thread.messages;
const msgMap = new Map<string, ChatMessage>();
messages.forEach(m => msgMap.set(m.id, m));
let headId = thread.activeHeadMessageId;
if (!headId || !msgMap.has(headId)) {
headId = messages[messages.length - 1].id;
}
const path: ChatMessage[] = [];
let currentId: string | null | undefined = headId;
const visited = new Set<string>();
while (currentId && msgMap.has(currentId) && !visited.has(currentId)) {
visited.add(currentId);
const msg = msgMap.get(currentId)!;
path.push(msg);
currentId = msg.parentId;
}
if (path.length > 0) {
return path.reverse();
}
return messages;
}private async handlePivotInit(ws: WebSocket, payload: any) {
const { activeThreadId, interruptedNodeId, userPrompt, newBranchNodeId } = payload;
// 1. Hot Halt Active LLM Task
const activeStream = this.activeStreams.get(activeThreadId);
if (activeStream) {
activeStream.abortController.abort();
this.activeStreams.delete(activeThreadId);
}
// 2. Transmit Halt Confirmation
ws.send(JSON.stringify({
type: 'CPP_STREAM_HALTED',
timestamp: Date.now(),
payload: {
interruptedNodeId,
finalContentLength: 100,
lastChunkReceived: "[Halted via Conversational Pivot Protocol]"
}
}));
}Download the complete, detailed 800+ line markdown integration manual with WebSocket frames, state controllers, and interactive UI views.