FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
opencode/packages/opencode/src/session/message.ts at dev · argszero/opencode · GitHub
argszero
/
opencode
Public
forked from
anomalyco/opencode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
opencode
/
packages
/
opencode
/
src
/
session
/
message.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
148 lines (134 loc) · 4.92 KB
Breadcrumbs
opencode
/
packages
/
opencode
/
src
/
session
/
message.ts
Copy path
File metadata and controls
148 lines (134 loc) · 4.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import
{
Schema
}
from
"effect"
import
{
SessionID
}
from
"./schema"
import
{
NonNegativeInt
}
from
"@opencode-ai/core/schema"
import
{
MessageError
}
from
"./message-error"
import
{
AuthError
,
OutputLengthError
}
from
"./message-error"
import
{
ProviderV2
}
from
"@opencode-ai/core/provider"
import
{
ModelV2
}
from
"@opencode-ai/core/model"
export
{
AuthError
,
OutputLengthError
}
from
"./message-error"
export
const
ToolCall
=
Schema
.
Struct
(
{
state
:
Schema
.
Literal
(
"call"
)
,
step
:
Schema
.
optional
(
NonNegativeInt
)
,
toolCallId
:
Schema
.
String
,
toolName
:
Schema
.
String
,
args
:
Schema
.
Unknown
,
}
)
.
annotate
(
{
identifier
:
"ToolCall"
}
)
export
type
ToolCall
=
Schema
.
Schema
.
Type
<
typeof
ToolCall
>
export
const
ToolPartialCall
=
Schema
.
Struct
(
{
state
:
Schema
.
Literal
(
"partial-call"
)
,
step
:
Schema
.
optional
(
NonNegativeInt
)
,
toolCallId
:
Schema
.
String
,
toolName
:
Schema
.
String
,
args
:
Schema
.
Unknown
,
}
)
.
annotate
(
{
identifier
:
"ToolPartialCall"
}
)
export
type
ToolPartialCall
=
Schema
.
Schema
.
Type
<
typeof
ToolPartialCall
>
export
const
ToolResult
=
Schema
.
Struct
(
{
state
:
Schema
.
Literal
(
"result"
)
,
step
:
Schema
.
optional
(
NonNegativeInt
)
,
toolCallId
:
Schema
.
String
,
toolName
:
Schema
.
String
,
args
:
Schema
.
Unknown
,
result
:
Schema
.
String
,
}
)
.
annotate
(
{
identifier
:
"ToolResult"
}
)
export
type
ToolResult
=
Schema
.
Schema
.
Type
<
typeof
ToolResult
>
export
const
ToolInvocation
=
Schema
.
Union
(
[
ToolCall
,
ToolPartialCall
,
ToolResult
]
)
.
annotate
(
{
identifier
:
"ToolInvocation"
,
discriminator
:
"state"
,
}
)
export
type
ToolInvocation
=
Schema
.
Schema
.
Type
<
typeof
ToolInvocation
>
export
const
TextPart
=
Schema
.
Struct
(
{
type
:
Schema
.
Literal
(
"text"
)
,
text
:
Schema
.
String
,
}
)
.
annotate
(
{
identifier
:
"TextPart"
}
)
export
type
TextPart
=
Schema
.
Schema
.
Type
<
typeof
TextPart
>
export
const
ReasoningPart
=
Schema
.
Struct
(
{
type
:
Schema
.
Literal
(
"reasoning"
)
,
text
:
Schema
.
String
,
providerMetadata
:
Schema
.
optional
(
Schema
.
Record
(
Schema
.
String
,
Schema
.
Unknown
)
)
,
}
)
.
annotate
(
{
identifier
:
"ReasoningPart"
}
)
export
type
ReasoningPart
=
Schema
.
Schema
.
Type
<
typeof
ReasoningPart
>
export
const
ToolInvocationPart
=
Schema
.
Struct
(
{
type
:
Schema
.
Literal
(
"tool-invocation"
)
,
toolInvocation
:
ToolInvocation
,
}
)
.
annotate
(
{
identifier
:
"ToolInvocationPart"
}
)
export
type
ToolInvocationPart
=
Schema
.
Schema
.
Type
<
typeof
ToolInvocationPart
>
export
const
SourceUrlPart
=
Schema
.
Struct
(
{
type
:
Schema
.
Literal
(
"source-url"
)
,
sourceId
:
Schema
.
String
,
url
:
Schema
.
String
,
title
:
Schema
.
optional
(
Schema
.
String
)
,
providerMetadata
:
Schema
.
optional
(
Schema
.
Record
(
Schema
.
String
,
Schema
.
Unknown
)
)
,
}
)
.
annotate
(
{
identifier
:
"SourceUrlPart"
}
)
export
type
SourceUrlPart
=
Schema
.
Schema
.
Type
<
typeof
SourceUrlPart
>
export
const
FilePart
=
Schema
.
Struct
(
{
type
:
Schema
.
Literal
(
"file"
)
,
mediaType
:
Schema
.
String
,
filename
:
Schema
.
optional
(
Schema
.
String
)
,
url
:
Schema
.
String
,
}
)
.
annotate
(
{
identifier
:
"FilePart"
}
)
export
type
FilePart
=
Schema
.
Schema
.
Type
<
typeof
FilePart
>
export
const
StepStartPart
=
Schema
.
Struct
(
{
type
:
Schema
.
Literal
(
"step-start"
)
,
}
)
.
annotate
(
{
identifier
:
"StepStartPart"
}
)
export
type
StepStartPart
=
Schema
.
Schema
.
Type
<
typeof
StepStartPart
>
export
const
MessagePart
=
Schema
.
Union
(
[
TextPart
,
ReasoningPart
,
ToolInvocationPart
,
SourceUrlPart
,
FilePart
,
StepStartPart
,
]
)
.
annotate
(
{
identifier
:
"MessagePart"
,
discriminator
:
"type"
}
)
export
type
MessagePart
=
Schema
.
Schema
.
Type
<
typeof
MessagePart
>
export
const
Info
=
Schema
.
Struct
(
{
id
:
Schema
.
String
,
role
:
Schema
.
Literals
(
[
"user"
,
"assistant"
]
)
,
parts
:
Schema
.
Array
(
MessagePart
)
,
metadata
:
Schema
.
Struct
(
{
time
:
Schema
.
Struct
(
{
created
:
NonNegativeInt
,
completed
:
Schema
.
optional
(
NonNegativeInt
)
,
}
)
,
error
:
Schema
.
optional
(
MessageError
.
SharedSchema
)
,
sessionID
:
SessionID
,
tool
:
Schema
.
Record
(
Schema
.
String
,
Schema
.
StructWithRest
(
Schema
.
Struct
(
{
title
:
Schema
.
String
,
snapshot
:
Schema
.
optional
(
Schema
.
String
)
,
time
:
Schema
.
Struct
(
{
start
:
NonNegativeInt
,
end
:
NonNegativeInt
,
}
)
,
}
)
,
[
Schema
.
Record
(
Schema
.
String
,
Schema
.
Unknown
)
]
,
)
,
)
,
assistant
:
Schema
.
optional
(
Schema
.
Struct
(
{
system
:
Schema
.
Array
(
Schema
.
String
)
,
modelID
:
ModelV2
.
ID
,
providerID
:
ProviderV2
.
ID
,
path
:
Schema
.
Struct
(
{
cwd
:
Schema
.
String
,
root
:
Schema
.
String
,
}
)
,
cost
:
Schema
.
Finite
,
summary
:
Schema
.
optional
(
Schema
.
Boolean
)
,
tokens
:
Schema
.
Struct
(
{
input
:
Schema
.
Finite
,
output
:
Schema
.
Finite
,
reasoning
:
Schema
.
Finite
,
cache
:
Schema
.
Struct
(
{
read
:
Schema
.
Finite
,
write
:
Schema
.
Finite
,
}
)
,
}
)
,
}
)
,
)
,
snapshot
:
Schema
.
optional
(
Schema
.
String
)
,
}
)
.
annotate
(
{
identifier
:
"MessageMetadata"
}
)
,
}
)
.
annotate
(
{
identifier
:
"Message"
}
)
export
type
Info
=
Schema
.
Schema
.
Type
<
typeof
Info
>
export
*
as
Message
from
"./message"
Back
|
FazBrowse Home
|
New Git URL