feat: project Pi conversation events

This commit is contained in:
2026-08-23 08:07:33 +08:00
parent e79aeffffa
commit 3599064bc4
11 changed files with 2428 additions and 32 deletions

View File

@@ -0,0 +1,123 @@
// Captured against @earendil-works/pi-coding-agent@0.84.2 RPC/session shapes.
export const PI_084_TEXT_TURN = {
usage: {
input: 12,
output: 4,
cacheRead: 2,
cacheWrite: 0,
totalTokens: 18,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
events: [
{
type: 'message_start',
message: { role: 'user', content: 'Implement the change', timestamp: 1 },
},
{
type: 'message_start',
message: {
role: 'assistant',
content: [],
usage: {
input: 12,
output: 4,
cacheRead: 2,
cacheWrite: 0,
totalTokens: 18,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
stopReason: 'stop',
timestamp: 2,
},
},
{
type: 'message_update',
assistantMessageEvent: { type: 'text_start', contentIndex: 0 },
usage: {
input: 12,
output: 4,
cacheRead: 2,
cacheWrite: 0,
totalTokens: 18,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
},
{
type: 'message_update',
assistantMessageEvent: { type: 'text_delta', contentIndex: 0, delta: 'Implemented' },
usage: {
input: 12,
output: 4,
cacheRead: 2,
cacheWrite: 0,
totalTokens: 18,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
},
{
type: 'message_update',
assistantMessageEvent: { type: 'text_end', contentIndex: 0, content: 'Implemented' },
usage: {
input: 12,
output: 4,
cacheRead: 2,
cacheWrite: 0,
totalTokens: 18,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
},
{
type: 'message_end',
message: {
role: 'assistant',
content: [{ type: 'text', text: 'Implemented' }],
usage: {
input: 12,
output: 4,
cacheRead: 2,
cacheWrite: 0,
totalTokens: 18,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
stopReason: 'stop',
timestamp: 2,
},
},
],
entries: {
leafId: 'entry-assistant-a',
entries: [
{
type: 'message',
id: 'entry-user-a',
parentId: null,
timestamp: '2026-08-23T00:00:00.000Z',
message: { role: 'user', content: 'Implement the change', timestamp: 1 },
},
{
type: 'message',
id: 'entry-assistant-a',
parentId: 'entry-user-a',
timestamp: '2026-08-23T00:00:01.000Z',
message: {
role: 'assistant',
content: [{ type: 'text', text: 'Implemented' }],
usage: {
input: 12,
output: 4,
cacheRead: 2,
cacheWrite: 0,
totalTokens: 18,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
stopReason: 'stop',
timestamp: 2,
},
},
],
},
stats: {
contextUsage: { tokens: 18, contextWindow: 100_000, percent: 0.018 },
tokens: { input: 12, output: 4, cacheRead: 2, cacheWrite: 0, total: 18 },
},
} as const;