feat(sdk): unify session event stream

This commit is contained in:
Kit Langton 2026-06-25 23:26:07 -04:00
commit 605fb0b6c5
20 changed files with 583 additions and 95 deletions

View file

@ -5713,7 +5713,7 @@ export class Session3 extends HeyApiClient {
/**
* Subscribe to session events
*
* Replay durable events after an aggregate sequence, then continue with new durable events.
* Replay durable events after an aggregate sequence, emit current process-local activity, then continue with durable and live-only Session events.
*/
public events<ThrowOnError extends boolean = false>(
parameters: {

View file

@ -4036,6 +4036,24 @@ export type SessionMessage =
| SessionMessageAssistant
| SessionMessageCompaction
export type SessionActivity = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.activity"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
sessionID: string
active: boolean
}
}
export type SessionNextAgentSwitched = {
id: string
metadata?: {
@ -4313,6 +4331,27 @@ export type SessionNextTextStarted = {
}
}
export type SessionNextTextDelta = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.text.delta"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
assistantMessageID: string
textID: string
delta: string
}
}
export type SessionNextTextEnded = {
id: string
metadata?: {
@ -4334,6 +4373,70 @@ export type SessionNextTextEnded = {
}
}
export type SessionNextReasoningStarted = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.reasoning.started"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
assistantMessageID: string
reasoningID: string
providerMetadata?: LlmProviderMetadata
}
}
export type SessionNextReasoningDelta = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.reasoning.delta"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
assistantMessageID: string
reasoningID: string
delta: string
}
}
export type SessionNextReasoningEnded = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.reasoning.ended"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
assistantMessageID: string
reasoningID: string
text: string
providerMetadata?: LlmProviderMetadata
}
}
export type SessionNextToolInputStarted = {
id: string
metadata?: {
@ -4355,6 +4458,27 @@ export type SessionNextToolInputStarted = {
}
}
export type SessionNextToolInputDelta = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.tool.input.delta"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
assistantMessageID: string
callID: string
delta: string
}
}
export type SessionNextToolInputEnded = {
id: string
metadata?: {
@ -4484,49 +4608,6 @@ export type SessionNextToolFailed = {
}
}
export type SessionNextReasoningStarted = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.reasoning.started"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
assistantMessageID: string
reasoningID: string
providerMetadata?: LlmProviderMetadata
}
}
export type SessionNextReasoningEnded = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.reasoning.ended"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
assistantMessageID: string
reasoningID: string
text: string
providerMetadata?: LlmProviderMetadata
}
}
export type SessionNextRetried = {
id: string
metadata?: {
@ -4567,6 +4648,26 @@ export type SessionNextCompactionStarted = {
}
}
export type SessionNextCompactionDelta = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.compaction.delta"
durable?: {
aggregateID: string
seq: number | "NaN" | "Infinity" | "-Infinity"
version: number | "NaN" | "Infinity" | "-Infinity"
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
messageID: string
text: string
}
}
export type SessionNextCompactionEnded = {
id: string
metadata?: {