fix(core): finalize v2 session context epochs

This commit is contained in:
Kit Langton 2026-06-04 21:17:05 -04:00
commit cd812e2045
33 changed files with 1245 additions and 791 deletions

View file

@ -21,6 +21,7 @@ export type Event =
| EventSessionNextPrompted
| EventSessionNextPromptAdmitted
| EventSessionNextPromptPromoted
| EventSessionNextContextUpdated
| EventSessionNextSynthetic
| EventSessionNextShellStarted
| EventSessionNextShellEnded
@ -867,6 +868,16 @@ export type GlobalEvent = {
timeCreated: number
}
}
| {
id: string
type: "session.next.context.updated"
properties: {
timestamp: number
sessionID: string
messageID: string
text: string
}
}
| {
id: string
type: "session.next.synthetic"
@ -1615,6 +1626,7 @@ export type GlobalEvent = {
| SyncEventSessionNextPrompted
| SyncEventSessionNextPromptAdmitted
| SyncEventSessionNextPromptPromoted
| SyncEventSessionNextContextUpdated
| SyncEventSessionNextSynthetic
| SyncEventSessionNextShellStarted
| SyncEventSessionNextShellEnded
@ -3259,6 +3271,23 @@ export type SyncEventSessionNextPromptPromoted = {
}
}
export type SyncEventSessionNextContextUpdated = {
type: "sync"
id: string
syncEvent: {
type: "session.next.context.updated.1"
id: string
seq: number
aggregateID: string
data: {
timestamp: number
sessionID: string
messageID: string
text: string
}
}
}
export type SyncEventSessionNextSynthetic = {
type: "sync"
id: string
@ -3822,6 +3851,18 @@ export type SessionMessageSynthetic = {
type: "synthetic"
}
export type SessionMessageSystem = {
id: string
metadata?: {
[key: string]: unknown
}
time: {
created: number
}
type: "system"
text: string
}
export type SessionMessageShell = {
id: string
metadata?: {
@ -3980,6 +4021,7 @@ export type SessionMessage =
| SessionMessageModelSwitched
| SessionMessageUser
| SessionMessageSynthetic
| SessionMessageSystem
| SessionMessageShell
| SessionMessageAssistant
| SessionMessageCompaction
@ -4339,6 +4381,17 @@ export type EventSessionNextPromptPromoted = {
}
}
export type EventSessionNextContextUpdated = {
id: string
type: "session.next.context.updated"
properties: {
timestamp: number
sessionID: string
messageID: string
text: string
}
}
export type EventSessionNextSynthetic = {
id: string
type: "session.next.synthetic"

View file

@ -12026,6 +12026,9 @@
{
"$ref": "#/components/schemas/EventSessionNextPromptPromoted"
},
{
"$ref": "#/components/schemas/EventSessionNextContextUpdated"
},
{
"$ref": "#/components/schemas/EventSessionNextSynthetic"
},
@ -14621,6 +14624,42 @@
"required": ["id", "type", "properties"],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^evt_"
},
"type": {
"type": "string",
"enum": ["session.next.context.updated"]
},
"properties": {
"type": "object",
"properties": {
"timestamp": {
"type": "number"
},
"sessionID": {
"type": "string",
"pattern": "^ses"
},
"messageID": {
"type": "string",
"pattern": "^msg_"
},
"text": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "messageID", "text"],
"additionalProperties": false
}
},
"required": ["id", "type", "properties"],
"additionalProperties": false
},
{
"type": "object",
"properties": {
@ -17142,6 +17181,9 @@
{
"$ref": "#/components/schemas/SyncEventSessionNextPromptPromoted"
},
{
"$ref": "#/components/schemas/SyncEventSessionNextContextUpdated"
},
{
"$ref": "#/components/schemas/SyncEventSessionNextSynthetic"
},
@ -21870,6 +21912,63 @@
"required": ["type", "id", "syncEvent"],
"additionalProperties": false
},
"SyncEventSessionNextContextUpdated": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["sync"]
},
"id": {
"type": "string",
"pattern": "^evt_"
},
"syncEvent": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["session.next.context.updated.1"]
},
"id": {
"type": "string",
"pattern": "^evt_"
},
"seq": {
"type": "number"
},
"aggregateID": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"timestamp": {
"type": "number"
},
"sessionID": {
"type": "string",
"pattern": "^ses"
},
"messageID": {
"type": "string",
"pattern": "^msg_"
},
"text": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "messageID", "text"],
"additionalProperties": false
}
},
"required": ["type", "id", "seq", "aggregateID", "data"],
"additionalProperties": false
}
},
"required": ["type", "id", "syncEvent"],
"additionalProperties": false
},
"SyncEventSessionNextSynthetic": {
"type": "object",
"properties": {
@ -23634,6 +23733,37 @@
"required": ["id", "time", "sessionID", "text", "type"],
"additionalProperties": false
},
"SessionMessageSystem": {
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^msg_"
},
"metadata": {
"type": "object"
},
"time": {
"type": "object",
"properties": {
"created": {
"type": "number"
}
},
"required": ["created"],
"additionalProperties": false
},
"type": {
"type": "string",
"enum": ["system"]
},
"text": {
"type": "string"
}
},
"required": ["id", "time", "type", "text"],
"additionalProperties": false
},
"SessionMessageShell": {
"type": "object",
"properties": {
@ -24071,6 +24201,9 @@
{
"$ref": "#/components/schemas/SessionMessageSynthetic"
},
{
"$ref": "#/components/schemas/SessionMessageSystem"
},
{
"$ref": "#/components/schemas/SessionMessageShell"
},
@ -25174,6 +25307,42 @@
"required": ["id", "type", "properties"],
"additionalProperties": false
},
"EventSessionNextContextUpdated": {
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^evt_"
},
"type": {
"type": "string",
"enum": ["session.next.context.updated"]
},
"properties": {
"type": "object",
"properties": {
"timestamp": {
"type": "number"
},
"sessionID": {
"type": "string",
"pattern": "^ses"
},
"messageID": {
"type": "string",
"pattern": "^msg_"
},
"text": {
"type": "string"
}
},
"required": ["timestamp", "sessionID", "messageID", "text"],
"additionalProperties": false
}
},
"required": ["id", "type", "properties"],
"additionalProperties": false
},
"EventSessionNextSynthetic": {
"type": "object",
"properties": {