feat: project Pi conversation events
This commit is contained in:
@@ -71,6 +71,7 @@ const PATCH_OPS = new Set([
|
||||
'message.block-delta',
|
||||
'tool.upsert',
|
||||
'compaction.upsert',
|
||||
'boundary.upsert',
|
||||
'subagent.upsert',
|
||||
'queue.replace',
|
||||
'interaction.upsert',
|
||||
@@ -301,6 +302,7 @@ export function isConversationSnapshot(value: unknown): value is ConversationSna
|
||||
&& typeof context.usedTokens === 'number'
|
||||
&& typeof context.contextWindow === 'number'
|
||||
&& ['idle', 'running'].includes(String(context.compaction))
|
||||
&& (context.recalculating === undefined || typeof context.recalculating === 'boolean')
|
||||
&& Array.isArray(record.pendingInteractions)
|
||||
&& record.pendingInteractions.every(isInteraction)
|
||||
&& isWorkerState(worker)
|
||||
@@ -328,6 +330,8 @@ function isPatch(value: unknown): value is ConversationPatch {
|
||||
return isToolNode(record.node);
|
||||
case 'compaction.upsert':
|
||||
return isConversationNode(record.node) && record.node.kind === 'compaction';
|
||||
case 'boundary.upsert':
|
||||
return isConversationNode(record.node) && record.node.kind === 'boundary';
|
||||
case 'subagent.upsert':
|
||||
return isSubagentNode(record.node);
|
||||
case 'queue.replace':
|
||||
@@ -341,7 +345,8 @@ function isPatch(value: unknown): value is ConversationPatch {
|
||||
return context !== null
|
||||
&& typeof context.usedTokens === 'number'
|
||||
&& typeof context.contextWindow === 'number'
|
||||
&& ['idle', 'running'].includes(String(context.compaction));
|
||||
&& ['idle', 'running'].includes(String(context.compaction))
|
||||
&& (context.recalculating === undefined || typeof context.recalculating === 'boolean');
|
||||
}
|
||||
case 'snapshot.invalidated':
|
||||
return isNonEmptyString(record.reason);
|
||||
@@ -456,6 +461,7 @@ function applyPatch(
|
||||
case 'tool.upsert':
|
||||
return { snapshot: { ...snapshot, nodes: upsertTool(snapshot.nodes, patch.node) } };
|
||||
case 'compaction.upsert':
|
||||
case 'boundary.upsert':
|
||||
case 'subagent.upsert':
|
||||
return { snapshot: { ...snapshot, nodes: upsertById(snapshot.nodes, patch.node) } };
|
||||
case 'queue.replace':
|
||||
|
||||
Reference in New Issue
Block a user