feat(core): compact v2 session context (#30986)

This commit is contained in:
Kit Langton 2026-06-05 13:17:23 -04:00 committed by GitHub
commit beae7290f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 569 additions and 296 deletions

View file

@ -1177,6 +1177,7 @@ export type GlobalEvent = {
properties: {
timestamp: number
sessionID: string
messageID: string
text: string
}
}
@ -1186,8 +1187,10 @@ export type GlobalEvent = {
properties: {
timestamp: number
sessionID: string
messageID: string
reason: "auto" | "manual"
text: string
include?: string
recent: string
}
}
| {
@ -1655,7 +1658,6 @@ export type GlobalEvent = {
| SyncEventSessionNextToolFailed
| SyncEventSessionNextRetried
| SyncEventSessionNextCompactionStarted
| SyncEventSessionNextCompactionDelta
| SyncEventSessionNextCompactionEnded
}
@ -3690,35 +3692,21 @@ export type SyncEventSessionNextCompactionStarted = {
}
}
export type SyncEventSessionNextCompactionDelta = {
type: "sync"
id: string
syncEvent: {
type: "session.next.compaction.delta.1"
id: string
seq: number
aggregateID: string
data: {
timestamp: number
sessionID: string
text: string
}
}
}
export type SyncEventSessionNextCompactionEnded = {
type: "sync"
id: string
syncEvent: {
type: "session.next.compaction.ended.1"
type: "session.next.compaction.ended.2"
id: string
seq: number
aggregateID: string
data: {
timestamp: number
sessionID: string
messageID: string
reason: "auto" | "manual"
text: string
include?: string
recent: string
}
}
}
@ -4031,7 +4019,7 @@ export type SessionMessageCompaction = {
type: "compaction"
reason: "auto" | "manual"
summary: string
include?: string
recent: string
id: string
metadata?: {
[key: string]: unknown
@ -4737,6 +4725,7 @@ export type EventSessionNextCompactionDelta = {
properties: {
timestamp: number
sessionID: string
messageID: string
text: string
}
}
@ -4747,8 +4736,10 @@ export type EventSessionNextCompactionEnded = {
properties: {
timestamp: number
sessionID: string
messageID: string
reason: "auto" | "manual"
text: string
include?: string
recent: string
}
}

View file

@ -15728,11 +15728,15 @@
"type": "string",
"pattern": "^ses"
},
"messageID": {
"type": "string",
"pattern": "^msg_"
},
"text": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "text"],
"required": ["timestamp", "sessionID", "messageID", "text"],
"additionalProperties": false
}
},
@ -15760,14 +15764,22 @@
"type": "string",
"pattern": "^ses"
},
"messageID": {
"type": "string",
"pattern": "^msg_"
},
"reason": {
"type": "string",
"enum": ["auto", "manual"]
},
"text": {
"type": "string"
},
"include": {
"recent": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "text"],
"required": ["timestamp", "sessionID", "messageID", "reason", "text", "recent"],
"additionalProperties": false
}
},
@ -17344,9 +17356,6 @@
{
"$ref": "#/components/schemas/SyncEventSessionNextCompactionStarted"
},
{
"$ref": "#/components/schemas/SyncEventSessionNextCompactionDelta"
},
{
"$ref": "#/components/schemas/SyncEventSessionNextCompactionEnded"
}
@ -23330,59 +23339,6 @@
"required": ["type", "id", "syncEvent"],
"additionalProperties": false
},
"SyncEventSessionNextCompactionDelta": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["sync"]
},
"id": {
"type": "string",
"pattern": "^evt_"
},
"syncEvent": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["session.next.compaction.delta.1"]
},
"id": {
"type": "string",
"pattern": "^evt_"
},
"seq": {
"type": "number"
},
"aggregateID": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"timestamp": {
"type": "number"
},
"sessionID": {
"type": "string",
"pattern": "^ses"
},
"text": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "text"],
"additionalProperties": false
}
},
"required": ["type", "id", "seq", "aggregateID", "data"],
"additionalProperties": false
}
},
"required": ["type", "id", "syncEvent"],
"additionalProperties": false
},
"SyncEventSessionNextCompactionEnded": {
"type": "object",
"properties": {
@ -23399,7 +23355,7 @@
"properties": {
"type": {
"type": "string",
"enum": ["session.next.compaction.ended.1"]
"enum": ["session.next.compaction.ended.2"]
},
"id": {
"type": "string",
@ -23421,14 +23377,22 @@
"type": "string",
"pattern": "^ses"
},
"messageID": {
"type": "string",
"pattern": "^msg_"
},
"reason": {
"type": "string",
"enum": ["auto", "manual"]
},
"text": {
"type": "string"
},
"include": {
"recent": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "text"],
"required": ["timestamp", "sessionID", "messageID", "reason", "text", "recent"],
"additionalProperties": false
}
},
@ -24319,7 +24283,7 @@
"summary": {
"type": "string"
},
"include": {
"recent": {
"type": "string"
},
"id": {
@ -24340,7 +24304,7 @@
"additionalProperties": false
}
},
"required": ["type", "reason", "summary", "id", "time"],
"required": ["type", "reason", "summary", "recent", "id", "time"],
"additionalProperties": false
},
"SessionMessage": {
@ -26485,11 +26449,15 @@
"type": "string",
"pattern": "^ses"
},
"messageID": {
"type": "string",
"pattern": "^msg_"
},
"text": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "text"],
"required": ["timestamp", "sessionID", "messageID", "text"],
"additionalProperties": false
}
},
@ -26517,14 +26485,22 @@
"type": "string",
"pattern": "^ses"
},
"messageID": {
"type": "string",
"pattern": "^msg_"
},
"reason": {
"type": "string",
"enum": ["auto", "manual"]
},
"text": {
"type": "string"
},
"include": {
"recent": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "text"],
"required": ["timestamp", "sessionID", "messageID", "reason", "text", "recent"],
"additionalProperties": false
}
},