-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtypes.ts
More file actions
115 lines (105 loc) · 3.19 KB
/
Copy pathtypes.ts
File metadata and controls
115 lines (105 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* Shared types for the space package.
*/
// ── Session Types ───────────────────────────────────────────────────
/** @deprecated Use SessionInfo from upstream-types.ts for API responses */
export interface InternalSessionInfo {
id: string
title: string
modelId: string
providerId: string
createdAt: number
updatedAt: number
}
export interface SessionMessage {
id: string
sessionId: string
role: "user" | "assistant" | "system" | "tool"
content: string
toolCalls?: ToolCallInfo[]
toolResults?: ToolResultInfo[]
createdAt: number
}
export interface ToolCallInfo {
id: string
name: string
arguments: Record<string, unknown>
}
export interface ToolResultInfo {
callId: string
name: string
result: string
isError?: boolean
}
// ── Stored Message Types (shared between DO and agent-loop) ─────────
export type StoredPart = {
id: string
sessionID: string
messageID: string
type: string
text?: string
time?: { start: number; end?: number }
reason?: string
cost?: number
tokens?: {
input: number
output: number
reasoning: number
cache: { read: number; write: number }
}
callID?: string
tool?: string
state?: {
status: string
input: Record<string, unknown>
raw?: string
title?: string
output?: string
metadata?: Record<string, unknown>
time?: { start: number; end?: number }
error?: string
}
metadata?: Record<string, unknown>
snapshot?: string
}
export interface StoredMessage {
info: {
id: string
sessionID: string
role: "user" | "assistant"
time: { created: number; completed?: number }
agent: string
model?: { providerID: string; modelID: string }
parentID?: string
modelID?: string
providerID?: string
mode?: string
path?: { cwd: string; root: string }
cost?: number
tokens?: {
total?: number
input: number
output: number
reasoning: number
cache: { read: number; write: number }
}
finish?: string
summary?: { diffs: unknown[] }
error?: unknown
}
parts: StoredPart[]
}
// ── Event Types ─────────────────────────────────────────────────────
export type SessionEvent =
| { type: "session.created"; session: InternalSessionInfo }
| { type: "session.updated"; session: Partial<InternalSessionInfo> & { id: string } }
| { type: "message.created"; message: SessionMessage }
| { type: "step.start"; sessionId: string; messageId: string }
| { type: "text.start"; sessionId: string; messageId: string }
| { type: "text.end"; sessionId: string; messageId: string }
| { type: "message.delta"; sessionId: string; messageId: string; delta: string }
| { type: "message.completed"; sessionId: string; messageId: string }
| { type: "tool.called"; sessionId: string; messageId: string; tool: ToolCallInfo }
| { type: "tool.result"; sessionId: string; messageId: string; result: ToolResultInfo }
| { type: "error"; sessionId?: string; error: string }
| { type: "done"; sessionId: string }