session.go 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. package opencode
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "net/http"
  8. "reflect"
  9. "github.com/sst/opencode-sdk-go/internal/apijson"
  10. "github.com/sst/opencode-sdk-go/internal/param"
  11. "github.com/sst/opencode-sdk-go/internal/requestconfig"
  12. "github.com/sst/opencode-sdk-go/option"
  13. "github.com/sst/opencode-sdk-go/shared"
  14. "github.com/tidwall/gjson"
  15. )
  16. // SessionService contains methods and other services that help with interacting
  17. // with the opencode API.
  18. //
  19. // Note, unlike clients, this service does not read variables from the environment
  20. // automatically. You should not instantiate this service directly, and instead use
  21. // the [NewSessionService] method instead.
  22. type SessionService struct {
  23. Options []option.RequestOption
  24. Permissions *SessionPermissionService
  25. }
  26. // NewSessionService generates a new service that applies the given options to each
  27. // request. These options are applied after the parent client's options (if there
  28. // is one), and before any request-specific options.
  29. func NewSessionService(opts ...option.RequestOption) (r *SessionService) {
  30. r = &SessionService{}
  31. r.Options = opts
  32. r.Permissions = NewSessionPermissionService(opts...)
  33. return
  34. }
  35. // Create a new session
  36. func (r *SessionService) New(ctx context.Context, body SessionNewParams, opts ...option.RequestOption) (res *Session, err error) {
  37. opts = append(r.Options[:], opts...)
  38. path := "session"
  39. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  40. return
  41. }
  42. // Update session properties
  43. func (r *SessionService) Update(ctx context.Context, id string, body SessionUpdateParams, opts ...option.RequestOption) (res *Session, err error) {
  44. opts = append(r.Options[:], opts...)
  45. if id == "" {
  46. err = errors.New("missing required id parameter")
  47. return
  48. }
  49. path := fmt.Sprintf("session/%s", id)
  50. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
  51. return
  52. }
  53. // List all sessions
  54. func (r *SessionService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Session, err error) {
  55. opts = append(r.Options[:], opts...)
  56. path := "session"
  57. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  58. return
  59. }
  60. // Delete a session and all its data
  61. func (r *SessionService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (res *bool, err error) {
  62. opts = append(r.Options[:], opts...)
  63. if id == "" {
  64. err = errors.New("missing required id parameter")
  65. return
  66. }
  67. path := fmt.Sprintf("session/%s", id)
  68. err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
  69. return
  70. }
  71. // Abort a session
  72. func (r *SessionService) Abort(ctx context.Context, id string, opts ...option.RequestOption) (res *bool, err error) {
  73. opts = append(r.Options[:], opts...)
  74. if id == "" {
  75. err = errors.New("missing required id parameter")
  76. return
  77. }
  78. path := fmt.Sprintf("session/%s/abort", id)
  79. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  80. return
  81. }
  82. // Create and send a new message to a session
  83. func (r *SessionService) Chat(ctx context.Context, id string, body SessionChatParams, opts ...option.RequestOption) (res *SessionChatResponse, err error) {
  84. opts = append(r.Options[:], opts...)
  85. if id == "" {
  86. err = errors.New("missing required id parameter")
  87. return
  88. }
  89. path := fmt.Sprintf("session/%s/message", id)
  90. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  91. return
  92. }
  93. // Get a session's children
  94. func (r *SessionService) Children(ctx context.Context, id string, opts ...option.RequestOption) (res *[]Session, err error) {
  95. opts = append(r.Options[:], opts...)
  96. if id == "" {
  97. err = errors.New("missing required id parameter")
  98. return
  99. }
  100. path := fmt.Sprintf("session/%s/children", id)
  101. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  102. return
  103. }
  104. // Send a new command to a session
  105. func (r *SessionService) Command(ctx context.Context, id string, body SessionCommandParams, opts ...option.RequestOption) (res *SessionCommandResponse, err error) {
  106. opts = append(r.Options[:], opts...)
  107. if id == "" {
  108. err = errors.New("missing required id parameter")
  109. return
  110. }
  111. path := fmt.Sprintf("session/%s/command", id)
  112. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  113. return
  114. }
  115. // Get session
  116. func (r *SessionService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  117. opts = append(r.Options[:], opts...)
  118. if id == "" {
  119. err = errors.New("missing required id parameter")
  120. return
  121. }
  122. path := fmt.Sprintf("session/%s", id)
  123. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  124. return
  125. }
  126. // Analyze the app and create an AGENTS.md file
  127. func (r *SessionService) Init(ctx context.Context, id string, body SessionInitParams, opts ...option.RequestOption) (res *bool, err error) {
  128. opts = append(r.Options[:], opts...)
  129. if id == "" {
  130. err = errors.New("missing required id parameter")
  131. return
  132. }
  133. path := fmt.Sprintf("session/%s/init", id)
  134. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  135. return
  136. }
  137. // Get a message from a session
  138. func (r *SessionService) Message(ctx context.Context, id string, messageID string, opts ...option.RequestOption) (res *SessionMessageResponse, err error) {
  139. opts = append(r.Options[:], opts...)
  140. if id == "" {
  141. err = errors.New("missing required id parameter")
  142. return
  143. }
  144. if messageID == "" {
  145. err = errors.New("missing required messageID parameter")
  146. return
  147. }
  148. path := fmt.Sprintf("session/%s/message/%s", id, messageID)
  149. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  150. return
  151. }
  152. // List messages for a session
  153. func (r *SessionService) Messages(ctx context.Context, id string, opts ...option.RequestOption) (res *[]SessionMessagesResponse, err error) {
  154. opts = append(r.Options[:], opts...)
  155. if id == "" {
  156. err = errors.New("missing required id parameter")
  157. return
  158. }
  159. path := fmt.Sprintf("session/%s/message", id)
  160. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  161. return
  162. }
  163. // Revert a message
  164. func (r *SessionService) Revert(ctx context.Context, id string, body SessionRevertParams, opts ...option.RequestOption) (res *Session, err error) {
  165. opts = append(r.Options[:], opts...)
  166. if id == "" {
  167. err = errors.New("missing required id parameter")
  168. return
  169. }
  170. path := fmt.Sprintf("session/%s/revert", id)
  171. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  172. return
  173. }
  174. // Share a session
  175. func (r *SessionService) Share(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  176. opts = append(r.Options[:], opts...)
  177. if id == "" {
  178. err = errors.New("missing required id parameter")
  179. return
  180. }
  181. path := fmt.Sprintf("session/%s/share", id)
  182. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  183. return
  184. }
  185. // Run a shell command
  186. func (r *SessionService) Shell(ctx context.Context, id string, body SessionShellParams, opts ...option.RequestOption) (res *AssistantMessage, err error) {
  187. opts = append(r.Options[:], opts...)
  188. if id == "" {
  189. err = errors.New("missing required id parameter")
  190. return
  191. }
  192. path := fmt.Sprintf("session/%s/shell", id)
  193. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  194. return
  195. }
  196. // Summarize the session
  197. func (r *SessionService) Summarize(ctx context.Context, id string, body SessionSummarizeParams, opts ...option.RequestOption) (res *bool, err error) {
  198. opts = append(r.Options[:], opts...)
  199. if id == "" {
  200. err = errors.New("missing required id parameter")
  201. return
  202. }
  203. path := fmt.Sprintf("session/%s/summarize", id)
  204. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  205. return
  206. }
  207. // Restore all reverted messages
  208. func (r *SessionService) Unrevert(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  209. opts = append(r.Options[:], opts...)
  210. if id == "" {
  211. err = errors.New("missing required id parameter")
  212. return
  213. }
  214. path := fmt.Sprintf("session/%s/unrevert", id)
  215. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  216. return
  217. }
  218. // Unshare the session
  219. func (r *SessionService) Unshare(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  220. opts = append(r.Options[:], opts...)
  221. if id == "" {
  222. err = errors.New("missing required id parameter")
  223. return
  224. }
  225. path := fmt.Sprintf("session/%s/share", id)
  226. err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
  227. return
  228. }
  229. type AgentPart struct {
  230. ID string `json:"id,required"`
  231. MessageID string `json:"messageID,required"`
  232. Name string `json:"name,required"`
  233. SessionID string `json:"sessionID,required"`
  234. Type AgentPartType `json:"type,required"`
  235. Source AgentPartSource `json:"source"`
  236. JSON agentPartJSON `json:"-"`
  237. }
  238. // agentPartJSON contains the JSON metadata for the struct [AgentPart]
  239. type agentPartJSON struct {
  240. ID apijson.Field
  241. MessageID apijson.Field
  242. Name apijson.Field
  243. SessionID apijson.Field
  244. Type apijson.Field
  245. Source apijson.Field
  246. raw string
  247. ExtraFields map[string]apijson.Field
  248. }
  249. func (r *AgentPart) UnmarshalJSON(data []byte) (err error) {
  250. return apijson.UnmarshalRoot(data, r)
  251. }
  252. func (r agentPartJSON) RawJSON() string {
  253. return r.raw
  254. }
  255. func (r AgentPart) implementsPart() {}
  256. type AgentPartType string
  257. const (
  258. AgentPartTypeAgent AgentPartType = "agent"
  259. )
  260. func (r AgentPartType) IsKnown() bool {
  261. switch r {
  262. case AgentPartTypeAgent:
  263. return true
  264. }
  265. return false
  266. }
  267. type AgentPartSource struct {
  268. End int64 `json:"end,required"`
  269. Start int64 `json:"start,required"`
  270. Value string `json:"value,required"`
  271. JSON agentPartSourceJSON `json:"-"`
  272. }
  273. // agentPartSourceJSON contains the JSON metadata for the struct [AgentPartSource]
  274. type agentPartSourceJSON struct {
  275. End apijson.Field
  276. Start apijson.Field
  277. Value apijson.Field
  278. raw string
  279. ExtraFields map[string]apijson.Field
  280. }
  281. func (r *AgentPartSource) UnmarshalJSON(data []byte) (err error) {
  282. return apijson.UnmarshalRoot(data, r)
  283. }
  284. func (r agentPartSourceJSON) RawJSON() string {
  285. return r.raw
  286. }
  287. type AgentPartInputParam struct {
  288. Name param.Field[string] `json:"name,required"`
  289. Type param.Field[AgentPartInputType] `json:"type,required"`
  290. ID param.Field[string] `json:"id"`
  291. Source param.Field[AgentPartInputSourceParam] `json:"source"`
  292. }
  293. func (r AgentPartInputParam) MarshalJSON() (data []byte, err error) {
  294. return apijson.MarshalRoot(r)
  295. }
  296. func (r AgentPartInputParam) implementsSessionChatParamsPartUnion() {}
  297. type AgentPartInputType string
  298. const (
  299. AgentPartInputTypeAgent AgentPartInputType = "agent"
  300. )
  301. func (r AgentPartInputType) IsKnown() bool {
  302. switch r {
  303. case AgentPartInputTypeAgent:
  304. return true
  305. }
  306. return false
  307. }
  308. type AgentPartInputSourceParam struct {
  309. End param.Field[int64] `json:"end,required"`
  310. Start param.Field[int64] `json:"start,required"`
  311. Value param.Field[string] `json:"value,required"`
  312. }
  313. func (r AgentPartInputSourceParam) MarshalJSON() (data []byte, err error) {
  314. return apijson.MarshalRoot(r)
  315. }
  316. type AssistantMessage struct {
  317. ID string `json:"id,required"`
  318. Cost float64 `json:"cost,required"`
  319. Mode string `json:"mode,required"`
  320. ModelID string `json:"modelID,required"`
  321. Path AssistantMessagePath `json:"path,required"`
  322. ProviderID string `json:"providerID,required"`
  323. Role AssistantMessageRole `json:"role,required"`
  324. SessionID string `json:"sessionID,required"`
  325. System []string `json:"system,required"`
  326. Time AssistantMessageTime `json:"time,required"`
  327. Tokens AssistantMessageTokens `json:"tokens,required"`
  328. Error AssistantMessageError `json:"error"`
  329. Summary bool `json:"summary"`
  330. JSON assistantMessageJSON `json:"-"`
  331. }
  332. // assistantMessageJSON contains the JSON metadata for the struct
  333. // [AssistantMessage]
  334. type assistantMessageJSON struct {
  335. ID apijson.Field
  336. Cost apijson.Field
  337. Mode apijson.Field
  338. ModelID apijson.Field
  339. Path apijson.Field
  340. ProviderID apijson.Field
  341. Role apijson.Field
  342. SessionID apijson.Field
  343. System apijson.Field
  344. Time apijson.Field
  345. Tokens apijson.Field
  346. Error apijson.Field
  347. Summary apijson.Field
  348. raw string
  349. ExtraFields map[string]apijson.Field
  350. }
  351. func (r *AssistantMessage) UnmarshalJSON(data []byte) (err error) {
  352. return apijson.UnmarshalRoot(data, r)
  353. }
  354. func (r assistantMessageJSON) RawJSON() string {
  355. return r.raw
  356. }
  357. func (r AssistantMessage) implementsMessage() {}
  358. type AssistantMessagePath struct {
  359. Cwd string `json:"cwd,required"`
  360. Root string `json:"root,required"`
  361. JSON assistantMessagePathJSON `json:"-"`
  362. }
  363. // assistantMessagePathJSON contains the JSON metadata for the struct
  364. // [AssistantMessagePath]
  365. type assistantMessagePathJSON struct {
  366. Cwd apijson.Field
  367. Root apijson.Field
  368. raw string
  369. ExtraFields map[string]apijson.Field
  370. }
  371. func (r *AssistantMessagePath) UnmarshalJSON(data []byte) (err error) {
  372. return apijson.UnmarshalRoot(data, r)
  373. }
  374. func (r assistantMessagePathJSON) RawJSON() string {
  375. return r.raw
  376. }
  377. type AssistantMessageRole string
  378. const (
  379. AssistantMessageRoleAssistant AssistantMessageRole = "assistant"
  380. )
  381. func (r AssistantMessageRole) IsKnown() bool {
  382. switch r {
  383. case AssistantMessageRoleAssistant:
  384. return true
  385. }
  386. return false
  387. }
  388. type AssistantMessageTime struct {
  389. Created float64 `json:"created,required"`
  390. Completed float64 `json:"completed"`
  391. JSON assistantMessageTimeJSON `json:"-"`
  392. }
  393. // assistantMessageTimeJSON contains the JSON metadata for the struct
  394. // [AssistantMessageTime]
  395. type assistantMessageTimeJSON struct {
  396. Created apijson.Field
  397. Completed apijson.Field
  398. raw string
  399. ExtraFields map[string]apijson.Field
  400. }
  401. func (r *AssistantMessageTime) UnmarshalJSON(data []byte) (err error) {
  402. return apijson.UnmarshalRoot(data, r)
  403. }
  404. func (r assistantMessageTimeJSON) RawJSON() string {
  405. return r.raw
  406. }
  407. type AssistantMessageTokens struct {
  408. Cache AssistantMessageTokensCache `json:"cache,required"`
  409. Input float64 `json:"input,required"`
  410. Output float64 `json:"output,required"`
  411. Reasoning float64 `json:"reasoning,required"`
  412. JSON assistantMessageTokensJSON `json:"-"`
  413. }
  414. // assistantMessageTokensJSON contains the JSON metadata for the struct
  415. // [AssistantMessageTokens]
  416. type assistantMessageTokensJSON struct {
  417. Cache apijson.Field
  418. Input apijson.Field
  419. Output apijson.Field
  420. Reasoning apijson.Field
  421. raw string
  422. ExtraFields map[string]apijson.Field
  423. }
  424. func (r *AssistantMessageTokens) UnmarshalJSON(data []byte) (err error) {
  425. return apijson.UnmarshalRoot(data, r)
  426. }
  427. func (r assistantMessageTokensJSON) RawJSON() string {
  428. return r.raw
  429. }
  430. type AssistantMessageTokensCache struct {
  431. Read float64 `json:"read,required"`
  432. Write float64 `json:"write,required"`
  433. JSON assistantMessageTokensCacheJSON `json:"-"`
  434. }
  435. // assistantMessageTokensCacheJSON contains the JSON metadata for the struct
  436. // [AssistantMessageTokensCache]
  437. type assistantMessageTokensCacheJSON struct {
  438. Read apijson.Field
  439. Write apijson.Field
  440. raw string
  441. ExtraFields map[string]apijson.Field
  442. }
  443. func (r *AssistantMessageTokensCache) UnmarshalJSON(data []byte) (err error) {
  444. return apijson.UnmarshalRoot(data, r)
  445. }
  446. func (r assistantMessageTokensCacheJSON) RawJSON() string {
  447. return r.raw
  448. }
  449. type AssistantMessageError struct {
  450. // This field can have the runtime type of [shared.ProviderAuthErrorData],
  451. // [shared.UnknownErrorData], [interface{}].
  452. Data interface{} `json:"data,required"`
  453. Name AssistantMessageErrorName `json:"name,required"`
  454. JSON assistantMessageErrorJSON `json:"-"`
  455. union AssistantMessageErrorUnion
  456. }
  457. // assistantMessageErrorJSON contains the JSON metadata for the struct
  458. // [AssistantMessageError]
  459. type assistantMessageErrorJSON struct {
  460. Data apijson.Field
  461. Name apijson.Field
  462. raw string
  463. ExtraFields map[string]apijson.Field
  464. }
  465. func (r assistantMessageErrorJSON) RawJSON() string {
  466. return r.raw
  467. }
  468. func (r *AssistantMessageError) UnmarshalJSON(data []byte) (err error) {
  469. *r = AssistantMessageError{}
  470. err = apijson.UnmarshalRoot(data, &r.union)
  471. if err != nil {
  472. return err
  473. }
  474. return apijson.Port(r.union, &r)
  475. }
  476. // AsUnion returns a [AssistantMessageErrorUnion] interface which you can cast to
  477. // the specific types for more type safety.
  478. //
  479. // Possible runtime types of the union are [shared.ProviderAuthError],
  480. // [shared.UnknownError], [AssistantMessageErrorMessageOutputLengthError],
  481. // [shared.MessageAbortedError].
  482. func (r AssistantMessageError) AsUnion() AssistantMessageErrorUnion {
  483. return r.union
  484. }
  485. // Union satisfied by [shared.ProviderAuthError], [shared.UnknownError],
  486. // [AssistantMessageErrorMessageOutputLengthError] or [shared.MessageAbortedError].
  487. type AssistantMessageErrorUnion interface {
  488. ImplementsAssistantMessageError()
  489. }
  490. func init() {
  491. apijson.RegisterUnion(
  492. reflect.TypeOf((*AssistantMessageErrorUnion)(nil)).Elem(),
  493. "name",
  494. apijson.UnionVariant{
  495. TypeFilter: gjson.JSON,
  496. Type: reflect.TypeOf(shared.ProviderAuthError{}),
  497. DiscriminatorValue: "ProviderAuthError",
  498. },
  499. apijson.UnionVariant{
  500. TypeFilter: gjson.JSON,
  501. Type: reflect.TypeOf(shared.UnknownError{}),
  502. DiscriminatorValue: "UnknownError",
  503. },
  504. apijson.UnionVariant{
  505. TypeFilter: gjson.JSON,
  506. Type: reflect.TypeOf(AssistantMessageErrorMessageOutputLengthError{}),
  507. DiscriminatorValue: "MessageOutputLengthError",
  508. },
  509. apijson.UnionVariant{
  510. TypeFilter: gjson.JSON,
  511. Type: reflect.TypeOf(shared.MessageAbortedError{}),
  512. DiscriminatorValue: "MessageAbortedError",
  513. },
  514. )
  515. }
  516. type AssistantMessageErrorMessageOutputLengthError struct {
  517. Data interface{} `json:"data,required"`
  518. Name AssistantMessageErrorMessageOutputLengthErrorName `json:"name,required"`
  519. JSON assistantMessageErrorMessageOutputLengthErrorJSON `json:"-"`
  520. }
  521. // assistantMessageErrorMessageOutputLengthErrorJSON contains the JSON metadata for
  522. // the struct [AssistantMessageErrorMessageOutputLengthError]
  523. type assistantMessageErrorMessageOutputLengthErrorJSON struct {
  524. Data apijson.Field
  525. Name apijson.Field
  526. raw string
  527. ExtraFields map[string]apijson.Field
  528. }
  529. func (r *AssistantMessageErrorMessageOutputLengthError) UnmarshalJSON(data []byte) (err error) {
  530. return apijson.UnmarshalRoot(data, r)
  531. }
  532. func (r assistantMessageErrorMessageOutputLengthErrorJSON) RawJSON() string {
  533. return r.raw
  534. }
  535. func (r AssistantMessageErrorMessageOutputLengthError) ImplementsAssistantMessageError() {}
  536. type AssistantMessageErrorMessageOutputLengthErrorName string
  537. const (
  538. AssistantMessageErrorMessageOutputLengthErrorNameMessageOutputLengthError AssistantMessageErrorMessageOutputLengthErrorName = "MessageOutputLengthError"
  539. )
  540. func (r AssistantMessageErrorMessageOutputLengthErrorName) IsKnown() bool {
  541. switch r {
  542. case AssistantMessageErrorMessageOutputLengthErrorNameMessageOutputLengthError:
  543. return true
  544. }
  545. return false
  546. }
  547. type AssistantMessageErrorName string
  548. const (
  549. AssistantMessageErrorNameProviderAuthError AssistantMessageErrorName = "ProviderAuthError"
  550. AssistantMessageErrorNameUnknownError AssistantMessageErrorName = "UnknownError"
  551. AssistantMessageErrorNameMessageOutputLengthError AssistantMessageErrorName = "MessageOutputLengthError"
  552. AssistantMessageErrorNameMessageAbortedError AssistantMessageErrorName = "MessageAbortedError"
  553. )
  554. func (r AssistantMessageErrorName) IsKnown() bool {
  555. switch r {
  556. case AssistantMessageErrorNameProviderAuthError, AssistantMessageErrorNameUnknownError, AssistantMessageErrorNameMessageOutputLengthError, AssistantMessageErrorNameMessageAbortedError:
  557. return true
  558. }
  559. return false
  560. }
  561. type FilePart struct {
  562. ID string `json:"id,required"`
  563. MessageID string `json:"messageID,required"`
  564. Mime string `json:"mime,required"`
  565. SessionID string `json:"sessionID,required"`
  566. Type FilePartType `json:"type,required"`
  567. URL string `json:"url,required"`
  568. Filename string `json:"filename"`
  569. Source FilePartSource `json:"source"`
  570. JSON filePartJSON `json:"-"`
  571. }
  572. // filePartJSON contains the JSON metadata for the struct [FilePart]
  573. type filePartJSON struct {
  574. ID apijson.Field
  575. MessageID apijson.Field
  576. Mime apijson.Field
  577. SessionID apijson.Field
  578. Type apijson.Field
  579. URL apijson.Field
  580. Filename apijson.Field
  581. Source apijson.Field
  582. raw string
  583. ExtraFields map[string]apijson.Field
  584. }
  585. func (r *FilePart) UnmarshalJSON(data []byte) (err error) {
  586. return apijson.UnmarshalRoot(data, r)
  587. }
  588. func (r filePartJSON) RawJSON() string {
  589. return r.raw
  590. }
  591. func (r FilePart) implementsPart() {}
  592. type FilePartType string
  593. const (
  594. FilePartTypeFile FilePartType = "file"
  595. )
  596. func (r FilePartType) IsKnown() bool {
  597. switch r {
  598. case FilePartTypeFile:
  599. return true
  600. }
  601. return false
  602. }
  603. type FilePartInputParam struct {
  604. Mime param.Field[string] `json:"mime,required"`
  605. Type param.Field[FilePartInputType] `json:"type,required"`
  606. URL param.Field[string] `json:"url,required"`
  607. ID param.Field[string] `json:"id"`
  608. Filename param.Field[string] `json:"filename"`
  609. Source param.Field[FilePartSourceUnionParam] `json:"source"`
  610. }
  611. func (r FilePartInputParam) MarshalJSON() (data []byte, err error) {
  612. return apijson.MarshalRoot(r)
  613. }
  614. func (r FilePartInputParam) implementsSessionChatParamsPartUnion() {}
  615. type FilePartInputType string
  616. const (
  617. FilePartInputTypeFile FilePartInputType = "file"
  618. )
  619. func (r FilePartInputType) IsKnown() bool {
  620. switch r {
  621. case FilePartInputTypeFile:
  622. return true
  623. }
  624. return false
  625. }
  626. type FilePartSource struct {
  627. Path string `json:"path,required"`
  628. Text FilePartSourceText `json:"text,required"`
  629. Type FilePartSourceType `json:"type,required"`
  630. Kind int64 `json:"kind"`
  631. Name string `json:"name"`
  632. // This field can have the runtime type of [SymbolSourceRange].
  633. Range interface{} `json:"range"`
  634. JSON filePartSourceJSON `json:"-"`
  635. union FilePartSourceUnion
  636. }
  637. // filePartSourceJSON contains the JSON metadata for the struct [FilePartSource]
  638. type filePartSourceJSON struct {
  639. Path apijson.Field
  640. Text apijson.Field
  641. Type apijson.Field
  642. Kind apijson.Field
  643. Name apijson.Field
  644. Range apijson.Field
  645. raw string
  646. ExtraFields map[string]apijson.Field
  647. }
  648. func (r filePartSourceJSON) RawJSON() string {
  649. return r.raw
  650. }
  651. func (r *FilePartSource) UnmarshalJSON(data []byte) (err error) {
  652. *r = FilePartSource{}
  653. err = apijson.UnmarshalRoot(data, &r.union)
  654. if err != nil {
  655. return err
  656. }
  657. return apijson.Port(r.union, &r)
  658. }
  659. // AsUnion returns a [FilePartSourceUnion] interface which you can cast to the
  660. // specific types for more type safety.
  661. //
  662. // Possible runtime types of the union are [FileSource], [SymbolSource].
  663. func (r FilePartSource) AsUnion() FilePartSourceUnion {
  664. return r.union
  665. }
  666. // Union satisfied by [FileSource] or [SymbolSource].
  667. type FilePartSourceUnion interface {
  668. implementsFilePartSource()
  669. }
  670. func init() {
  671. apijson.RegisterUnion(
  672. reflect.TypeOf((*FilePartSourceUnion)(nil)).Elem(),
  673. "type",
  674. apijson.UnionVariant{
  675. TypeFilter: gjson.JSON,
  676. Type: reflect.TypeOf(FileSource{}),
  677. DiscriminatorValue: "file",
  678. },
  679. apijson.UnionVariant{
  680. TypeFilter: gjson.JSON,
  681. Type: reflect.TypeOf(SymbolSource{}),
  682. DiscriminatorValue: "symbol",
  683. },
  684. )
  685. }
  686. type FilePartSourceType string
  687. const (
  688. FilePartSourceTypeFile FilePartSourceType = "file"
  689. FilePartSourceTypeSymbol FilePartSourceType = "symbol"
  690. )
  691. func (r FilePartSourceType) IsKnown() bool {
  692. switch r {
  693. case FilePartSourceTypeFile, FilePartSourceTypeSymbol:
  694. return true
  695. }
  696. return false
  697. }
  698. type FilePartSourceParam struct {
  699. Path param.Field[string] `json:"path,required"`
  700. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  701. Type param.Field[FilePartSourceType] `json:"type,required"`
  702. Kind param.Field[int64] `json:"kind"`
  703. Name param.Field[string] `json:"name"`
  704. Range param.Field[interface{}] `json:"range"`
  705. }
  706. func (r FilePartSourceParam) MarshalJSON() (data []byte, err error) {
  707. return apijson.MarshalRoot(r)
  708. }
  709. func (r FilePartSourceParam) implementsFilePartSourceUnionParam() {}
  710. // Satisfied by [FileSourceParam], [SymbolSourceParam], [FilePartSourceParam].
  711. type FilePartSourceUnionParam interface {
  712. implementsFilePartSourceUnionParam()
  713. }
  714. type FilePartSourceText struct {
  715. End int64 `json:"end,required"`
  716. Start int64 `json:"start,required"`
  717. Value string `json:"value,required"`
  718. JSON filePartSourceTextJSON `json:"-"`
  719. }
  720. // filePartSourceTextJSON contains the JSON metadata for the struct
  721. // [FilePartSourceText]
  722. type filePartSourceTextJSON struct {
  723. End apijson.Field
  724. Start apijson.Field
  725. Value apijson.Field
  726. raw string
  727. ExtraFields map[string]apijson.Field
  728. }
  729. func (r *FilePartSourceText) UnmarshalJSON(data []byte) (err error) {
  730. return apijson.UnmarshalRoot(data, r)
  731. }
  732. func (r filePartSourceTextJSON) RawJSON() string {
  733. return r.raw
  734. }
  735. type FilePartSourceTextParam struct {
  736. End param.Field[int64] `json:"end,required"`
  737. Start param.Field[int64] `json:"start,required"`
  738. Value param.Field[string] `json:"value,required"`
  739. }
  740. func (r FilePartSourceTextParam) MarshalJSON() (data []byte, err error) {
  741. return apijson.MarshalRoot(r)
  742. }
  743. type FileSource struct {
  744. Path string `json:"path,required"`
  745. Text FilePartSourceText `json:"text,required"`
  746. Type FileSourceType `json:"type,required"`
  747. JSON fileSourceJSON `json:"-"`
  748. }
  749. // fileSourceJSON contains the JSON metadata for the struct [FileSource]
  750. type fileSourceJSON struct {
  751. Path apijson.Field
  752. Text apijson.Field
  753. Type apijson.Field
  754. raw string
  755. ExtraFields map[string]apijson.Field
  756. }
  757. func (r *FileSource) UnmarshalJSON(data []byte) (err error) {
  758. return apijson.UnmarshalRoot(data, r)
  759. }
  760. func (r fileSourceJSON) RawJSON() string {
  761. return r.raw
  762. }
  763. func (r FileSource) implementsFilePartSource() {}
  764. type FileSourceType string
  765. const (
  766. FileSourceTypeFile FileSourceType = "file"
  767. )
  768. func (r FileSourceType) IsKnown() bool {
  769. switch r {
  770. case FileSourceTypeFile:
  771. return true
  772. }
  773. return false
  774. }
  775. type FileSourceParam struct {
  776. Path param.Field[string] `json:"path,required"`
  777. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  778. Type param.Field[FileSourceType] `json:"type,required"`
  779. }
  780. func (r FileSourceParam) MarshalJSON() (data []byte, err error) {
  781. return apijson.MarshalRoot(r)
  782. }
  783. func (r FileSourceParam) implementsFilePartSourceUnionParam() {}
  784. type Message struct {
  785. ID string `json:"id,required"`
  786. Role MessageRole `json:"role,required"`
  787. SessionID string `json:"sessionID,required"`
  788. // This field can have the runtime type of [UserMessageTime],
  789. // [AssistantMessageTime].
  790. Time interface{} `json:"time,required"`
  791. Cost float64 `json:"cost"`
  792. // This field can have the runtime type of [AssistantMessageError].
  793. Error interface{} `json:"error"`
  794. Mode string `json:"mode"`
  795. ModelID string `json:"modelID"`
  796. // This field can have the runtime type of [AssistantMessagePath].
  797. Path interface{} `json:"path"`
  798. ProviderID string `json:"providerID"`
  799. Summary bool `json:"summary"`
  800. // This field can have the runtime type of [[]string].
  801. System interface{} `json:"system"`
  802. // This field can have the runtime type of [AssistantMessageTokens].
  803. Tokens interface{} `json:"tokens"`
  804. JSON messageJSON `json:"-"`
  805. union MessageUnion
  806. }
  807. // messageJSON contains the JSON metadata for the struct [Message]
  808. type messageJSON struct {
  809. ID apijson.Field
  810. Role apijson.Field
  811. SessionID apijson.Field
  812. Time apijson.Field
  813. Cost apijson.Field
  814. Error apijson.Field
  815. Mode apijson.Field
  816. ModelID apijson.Field
  817. Path apijson.Field
  818. ProviderID apijson.Field
  819. Summary apijson.Field
  820. System apijson.Field
  821. Tokens apijson.Field
  822. raw string
  823. ExtraFields map[string]apijson.Field
  824. }
  825. func (r messageJSON) RawJSON() string {
  826. return r.raw
  827. }
  828. func (r *Message) UnmarshalJSON(data []byte) (err error) {
  829. *r = Message{}
  830. err = apijson.UnmarshalRoot(data, &r.union)
  831. if err != nil {
  832. return err
  833. }
  834. return apijson.Port(r.union, &r)
  835. }
  836. // AsUnion returns a [MessageUnion] interface which you can cast to the specific
  837. // types for more type safety.
  838. //
  839. // Possible runtime types of the union are [UserMessage], [AssistantMessage].
  840. func (r Message) AsUnion() MessageUnion {
  841. return r.union
  842. }
  843. // Union satisfied by [UserMessage] or [AssistantMessage].
  844. type MessageUnion interface {
  845. implementsMessage()
  846. }
  847. func init() {
  848. apijson.RegisterUnion(
  849. reflect.TypeOf((*MessageUnion)(nil)).Elem(),
  850. "role",
  851. apijson.UnionVariant{
  852. TypeFilter: gjson.JSON,
  853. Type: reflect.TypeOf(UserMessage{}),
  854. DiscriminatorValue: "user",
  855. },
  856. apijson.UnionVariant{
  857. TypeFilter: gjson.JSON,
  858. Type: reflect.TypeOf(AssistantMessage{}),
  859. DiscriminatorValue: "assistant",
  860. },
  861. )
  862. }
  863. type MessageRole string
  864. const (
  865. MessageRoleUser MessageRole = "user"
  866. MessageRoleAssistant MessageRole = "assistant"
  867. )
  868. func (r MessageRole) IsKnown() bool {
  869. switch r {
  870. case MessageRoleUser, MessageRoleAssistant:
  871. return true
  872. }
  873. return false
  874. }
  875. type Part struct {
  876. ID string `json:"id,required"`
  877. MessageID string `json:"messageID,required"`
  878. SessionID string `json:"sessionID,required"`
  879. Type PartType `json:"type,required"`
  880. CallID string `json:"callID"`
  881. Cost float64 `json:"cost"`
  882. Filename string `json:"filename"`
  883. // This field can have the runtime type of [[]string].
  884. Files interface{} `json:"files"`
  885. Hash string `json:"hash"`
  886. // This field can have the runtime type of [map[string]interface{}].
  887. Metadata interface{} `json:"metadata"`
  888. Mime string `json:"mime"`
  889. Name string `json:"name"`
  890. Snapshot string `json:"snapshot"`
  891. // This field can have the runtime type of [FilePartSource], [AgentPartSource].
  892. Source interface{} `json:"source"`
  893. // This field can have the runtime type of [ToolPartState].
  894. State interface{} `json:"state"`
  895. Synthetic bool `json:"synthetic"`
  896. Text string `json:"text"`
  897. // This field can have the runtime type of [TextPartTime], [ReasoningPartTime].
  898. Time interface{} `json:"time"`
  899. // This field can have the runtime type of [StepFinishPartTokens].
  900. Tokens interface{} `json:"tokens"`
  901. Tool string `json:"tool"`
  902. URL string `json:"url"`
  903. JSON partJSON `json:"-"`
  904. union PartUnion
  905. }
  906. // partJSON contains the JSON metadata for the struct [Part]
  907. type partJSON struct {
  908. ID apijson.Field
  909. MessageID apijson.Field
  910. SessionID apijson.Field
  911. Type apijson.Field
  912. CallID apijson.Field
  913. Cost apijson.Field
  914. Filename apijson.Field
  915. Files apijson.Field
  916. Hash apijson.Field
  917. Metadata apijson.Field
  918. Mime apijson.Field
  919. Name apijson.Field
  920. Snapshot apijson.Field
  921. Source apijson.Field
  922. State apijson.Field
  923. Synthetic apijson.Field
  924. Text apijson.Field
  925. Time apijson.Field
  926. Tokens apijson.Field
  927. Tool apijson.Field
  928. URL apijson.Field
  929. raw string
  930. ExtraFields map[string]apijson.Field
  931. }
  932. func (r partJSON) RawJSON() string {
  933. return r.raw
  934. }
  935. func (r *Part) UnmarshalJSON(data []byte) (err error) {
  936. *r = Part{}
  937. err = apijson.UnmarshalRoot(data, &r.union)
  938. if err != nil {
  939. return err
  940. }
  941. return apijson.Port(r.union, &r)
  942. }
  943. // AsUnion returns a [PartUnion] interface which you can cast to the specific types
  944. // for more type safety.
  945. //
  946. // Possible runtime types of the union are [TextPart], [ReasoningPart], [FilePart],
  947. // [ToolPart], [StepStartPart], [StepFinishPart], [SnapshotPart], [PartPatchPart],
  948. // [AgentPart].
  949. func (r Part) AsUnion() PartUnion {
  950. return r.union
  951. }
  952. // Union satisfied by [TextPart], [ReasoningPart], [FilePart], [ToolPart],
  953. // [StepStartPart], [StepFinishPart], [SnapshotPart], [PartPatchPart] or
  954. // [AgentPart].
  955. type PartUnion interface {
  956. implementsPart()
  957. }
  958. func init() {
  959. apijson.RegisterUnion(
  960. reflect.TypeOf((*PartUnion)(nil)).Elem(),
  961. "type",
  962. apijson.UnionVariant{
  963. TypeFilter: gjson.JSON,
  964. Type: reflect.TypeOf(TextPart{}),
  965. DiscriminatorValue: "text",
  966. },
  967. apijson.UnionVariant{
  968. TypeFilter: gjson.JSON,
  969. Type: reflect.TypeOf(ReasoningPart{}),
  970. DiscriminatorValue: "reasoning",
  971. },
  972. apijson.UnionVariant{
  973. TypeFilter: gjson.JSON,
  974. Type: reflect.TypeOf(FilePart{}),
  975. DiscriminatorValue: "file",
  976. },
  977. apijson.UnionVariant{
  978. TypeFilter: gjson.JSON,
  979. Type: reflect.TypeOf(ToolPart{}),
  980. DiscriminatorValue: "tool",
  981. },
  982. apijson.UnionVariant{
  983. TypeFilter: gjson.JSON,
  984. Type: reflect.TypeOf(StepStartPart{}),
  985. DiscriminatorValue: "step-start",
  986. },
  987. apijson.UnionVariant{
  988. TypeFilter: gjson.JSON,
  989. Type: reflect.TypeOf(StepFinishPart{}),
  990. DiscriminatorValue: "step-finish",
  991. },
  992. apijson.UnionVariant{
  993. TypeFilter: gjson.JSON,
  994. Type: reflect.TypeOf(SnapshotPart{}),
  995. DiscriminatorValue: "snapshot",
  996. },
  997. apijson.UnionVariant{
  998. TypeFilter: gjson.JSON,
  999. Type: reflect.TypeOf(PartPatchPart{}),
  1000. DiscriminatorValue: "patch",
  1001. },
  1002. apijson.UnionVariant{
  1003. TypeFilter: gjson.JSON,
  1004. Type: reflect.TypeOf(AgentPart{}),
  1005. DiscriminatorValue: "agent",
  1006. },
  1007. )
  1008. }
  1009. type PartPatchPart struct {
  1010. ID string `json:"id,required"`
  1011. Files []string `json:"files,required"`
  1012. Hash string `json:"hash,required"`
  1013. MessageID string `json:"messageID,required"`
  1014. SessionID string `json:"sessionID,required"`
  1015. Type PartPatchPartType `json:"type,required"`
  1016. JSON partPatchPartJSON `json:"-"`
  1017. }
  1018. // partPatchPartJSON contains the JSON metadata for the struct [PartPatchPart]
  1019. type partPatchPartJSON struct {
  1020. ID apijson.Field
  1021. Files apijson.Field
  1022. Hash apijson.Field
  1023. MessageID apijson.Field
  1024. SessionID apijson.Field
  1025. Type apijson.Field
  1026. raw string
  1027. ExtraFields map[string]apijson.Field
  1028. }
  1029. func (r *PartPatchPart) UnmarshalJSON(data []byte) (err error) {
  1030. return apijson.UnmarshalRoot(data, r)
  1031. }
  1032. func (r partPatchPartJSON) RawJSON() string {
  1033. return r.raw
  1034. }
  1035. func (r PartPatchPart) implementsPart() {}
  1036. type PartPatchPartType string
  1037. const (
  1038. PartPatchPartTypePatch PartPatchPartType = "patch"
  1039. )
  1040. func (r PartPatchPartType) IsKnown() bool {
  1041. switch r {
  1042. case PartPatchPartTypePatch:
  1043. return true
  1044. }
  1045. return false
  1046. }
  1047. type PartType string
  1048. const (
  1049. PartTypeText PartType = "text"
  1050. PartTypeReasoning PartType = "reasoning"
  1051. PartTypeFile PartType = "file"
  1052. PartTypeTool PartType = "tool"
  1053. PartTypeStepStart PartType = "step-start"
  1054. PartTypeStepFinish PartType = "step-finish"
  1055. PartTypeSnapshot PartType = "snapshot"
  1056. PartTypePatch PartType = "patch"
  1057. PartTypeAgent PartType = "agent"
  1058. )
  1059. func (r PartType) IsKnown() bool {
  1060. switch r {
  1061. case PartTypeText, PartTypeReasoning, PartTypeFile, PartTypeTool, PartTypeStepStart, PartTypeStepFinish, PartTypeSnapshot, PartTypePatch, PartTypeAgent:
  1062. return true
  1063. }
  1064. return false
  1065. }
  1066. type ReasoningPart struct {
  1067. ID string `json:"id,required"`
  1068. MessageID string `json:"messageID,required"`
  1069. SessionID string `json:"sessionID,required"`
  1070. Text string `json:"text,required"`
  1071. Time ReasoningPartTime `json:"time,required"`
  1072. Type ReasoningPartType `json:"type,required"`
  1073. Metadata map[string]interface{} `json:"metadata"`
  1074. JSON reasoningPartJSON `json:"-"`
  1075. }
  1076. // reasoningPartJSON contains the JSON metadata for the struct [ReasoningPart]
  1077. type reasoningPartJSON struct {
  1078. ID apijson.Field
  1079. MessageID apijson.Field
  1080. SessionID apijson.Field
  1081. Text apijson.Field
  1082. Time apijson.Field
  1083. Type apijson.Field
  1084. Metadata apijson.Field
  1085. raw string
  1086. ExtraFields map[string]apijson.Field
  1087. }
  1088. func (r *ReasoningPart) UnmarshalJSON(data []byte) (err error) {
  1089. return apijson.UnmarshalRoot(data, r)
  1090. }
  1091. func (r reasoningPartJSON) RawJSON() string {
  1092. return r.raw
  1093. }
  1094. func (r ReasoningPart) implementsPart() {}
  1095. type ReasoningPartTime struct {
  1096. Start float64 `json:"start,required"`
  1097. End float64 `json:"end"`
  1098. JSON reasoningPartTimeJSON `json:"-"`
  1099. }
  1100. // reasoningPartTimeJSON contains the JSON metadata for the struct
  1101. // [ReasoningPartTime]
  1102. type reasoningPartTimeJSON struct {
  1103. Start apijson.Field
  1104. End apijson.Field
  1105. raw string
  1106. ExtraFields map[string]apijson.Field
  1107. }
  1108. func (r *ReasoningPartTime) UnmarshalJSON(data []byte) (err error) {
  1109. return apijson.UnmarshalRoot(data, r)
  1110. }
  1111. func (r reasoningPartTimeJSON) RawJSON() string {
  1112. return r.raw
  1113. }
  1114. type ReasoningPartType string
  1115. const (
  1116. ReasoningPartTypeReasoning ReasoningPartType = "reasoning"
  1117. )
  1118. func (r ReasoningPartType) IsKnown() bool {
  1119. switch r {
  1120. case ReasoningPartTypeReasoning:
  1121. return true
  1122. }
  1123. return false
  1124. }
  1125. type Session struct {
  1126. ID string `json:"id,required"`
  1127. Time SessionTime `json:"time,required"`
  1128. Title string `json:"title,required"`
  1129. Version string `json:"version,required"`
  1130. ParentID string `json:"parentID"`
  1131. Revert SessionRevert `json:"revert"`
  1132. Share SessionShare `json:"share"`
  1133. JSON sessionJSON `json:"-"`
  1134. }
  1135. // sessionJSON contains the JSON metadata for the struct [Session]
  1136. type sessionJSON struct {
  1137. ID apijson.Field
  1138. Time apijson.Field
  1139. Title apijson.Field
  1140. Version apijson.Field
  1141. ParentID apijson.Field
  1142. Revert apijson.Field
  1143. Share apijson.Field
  1144. raw string
  1145. ExtraFields map[string]apijson.Field
  1146. }
  1147. func (r *Session) UnmarshalJSON(data []byte) (err error) {
  1148. return apijson.UnmarshalRoot(data, r)
  1149. }
  1150. func (r sessionJSON) RawJSON() string {
  1151. return r.raw
  1152. }
  1153. type SessionTime struct {
  1154. Created float64 `json:"created,required"`
  1155. Updated float64 `json:"updated,required"`
  1156. JSON sessionTimeJSON `json:"-"`
  1157. }
  1158. // sessionTimeJSON contains the JSON metadata for the struct [SessionTime]
  1159. type sessionTimeJSON struct {
  1160. Created apijson.Field
  1161. Updated apijson.Field
  1162. raw string
  1163. ExtraFields map[string]apijson.Field
  1164. }
  1165. func (r *SessionTime) UnmarshalJSON(data []byte) (err error) {
  1166. return apijson.UnmarshalRoot(data, r)
  1167. }
  1168. func (r sessionTimeJSON) RawJSON() string {
  1169. return r.raw
  1170. }
  1171. type SessionRevert struct {
  1172. MessageID string `json:"messageID,required"`
  1173. Diff string `json:"diff"`
  1174. PartID string `json:"partID"`
  1175. Snapshot string `json:"snapshot"`
  1176. JSON sessionRevertJSON `json:"-"`
  1177. }
  1178. // sessionRevertJSON contains the JSON metadata for the struct [SessionRevert]
  1179. type sessionRevertJSON struct {
  1180. MessageID apijson.Field
  1181. Diff apijson.Field
  1182. PartID apijson.Field
  1183. Snapshot apijson.Field
  1184. raw string
  1185. ExtraFields map[string]apijson.Field
  1186. }
  1187. func (r *SessionRevert) UnmarshalJSON(data []byte) (err error) {
  1188. return apijson.UnmarshalRoot(data, r)
  1189. }
  1190. func (r sessionRevertJSON) RawJSON() string {
  1191. return r.raw
  1192. }
  1193. type SessionShare struct {
  1194. URL string `json:"url,required"`
  1195. JSON sessionShareJSON `json:"-"`
  1196. }
  1197. // sessionShareJSON contains the JSON metadata for the struct [SessionShare]
  1198. type sessionShareJSON struct {
  1199. URL apijson.Field
  1200. raw string
  1201. ExtraFields map[string]apijson.Field
  1202. }
  1203. func (r *SessionShare) UnmarshalJSON(data []byte) (err error) {
  1204. return apijson.UnmarshalRoot(data, r)
  1205. }
  1206. func (r sessionShareJSON) RawJSON() string {
  1207. return r.raw
  1208. }
  1209. type SnapshotPart struct {
  1210. ID string `json:"id,required"`
  1211. MessageID string `json:"messageID,required"`
  1212. SessionID string `json:"sessionID,required"`
  1213. Snapshot string `json:"snapshot,required"`
  1214. Type SnapshotPartType `json:"type,required"`
  1215. JSON snapshotPartJSON `json:"-"`
  1216. }
  1217. // snapshotPartJSON contains the JSON metadata for the struct [SnapshotPart]
  1218. type snapshotPartJSON struct {
  1219. ID apijson.Field
  1220. MessageID apijson.Field
  1221. SessionID apijson.Field
  1222. Snapshot apijson.Field
  1223. Type apijson.Field
  1224. raw string
  1225. ExtraFields map[string]apijson.Field
  1226. }
  1227. func (r *SnapshotPart) UnmarshalJSON(data []byte) (err error) {
  1228. return apijson.UnmarshalRoot(data, r)
  1229. }
  1230. func (r snapshotPartJSON) RawJSON() string {
  1231. return r.raw
  1232. }
  1233. func (r SnapshotPart) implementsPart() {}
  1234. type SnapshotPartType string
  1235. const (
  1236. SnapshotPartTypeSnapshot SnapshotPartType = "snapshot"
  1237. )
  1238. func (r SnapshotPartType) IsKnown() bool {
  1239. switch r {
  1240. case SnapshotPartTypeSnapshot:
  1241. return true
  1242. }
  1243. return false
  1244. }
  1245. type StepFinishPart struct {
  1246. ID string `json:"id,required"`
  1247. Cost float64 `json:"cost,required"`
  1248. MessageID string `json:"messageID,required"`
  1249. SessionID string `json:"sessionID,required"`
  1250. Tokens StepFinishPartTokens `json:"tokens,required"`
  1251. Type StepFinishPartType `json:"type,required"`
  1252. JSON stepFinishPartJSON `json:"-"`
  1253. }
  1254. // stepFinishPartJSON contains the JSON metadata for the struct [StepFinishPart]
  1255. type stepFinishPartJSON struct {
  1256. ID apijson.Field
  1257. Cost apijson.Field
  1258. MessageID apijson.Field
  1259. SessionID apijson.Field
  1260. Tokens apijson.Field
  1261. Type apijson.Field
  1262. raw string
  1263. ExtraFields map[string]apijson.Field
  1264. }
  1265. func (r *StepFinishPart) UnmarshalJSON(data []byte) (err error) {
  1266. return apijson.UnmarshalRoot(data, r)
  1267. }
  1268. func (r stepFinishPartJSON) RawJSON() string {
  1269. return r.raw
  1270. }
  1271. func (r StepFinishPart) implementsPart() {}
  1272. type StepFinishPartTokens struct {
  1273. Cache StepFinishPartTokensCache `json:"cache,required"`
  1274. Input float64 `json:"input,required"`
  1275. Output float64 `json:"output,required"`
  1276. Reasoning float64 `json:"reasoning,required"`
  1277. JSON stepFinishPartTokensJSON `json:"-"`
  1278. }
  1279. // stepFinishPartTokensJSON contains the JSON metadata for the struct
  1280. // [StepFinishPartTokens]
  1281. type stepFinishPartTokensJSON struct {
  1282. Cache apijson.Field
  1283. Input apijson.Field
  1284. Output apijson.Field
  1285. Reasoning apijson.Field
  1286. raw string
  1287. ExtraFields map[string]apijson.Field
  1288. }
  1289. func (r *StepFinishPartTokens) UnmarshalJSON(data []byte) (err error) {
  1290. return apijson.UnmarshalRoot(data, r)
  1291. }
  1292. func (r stepFinishPartTokensJSON) RawJSON() string {
  1293. return r.raw
  1294. }
  1295. type StepFinishPartTokensCache struct {
  1296. Read float64 `json:"read,required"`
  1297. Write float64 `json:"write,required"`
  1298. JSON stepFinishPartTokensCacheJSON `json:"-"`
  1299. }
  1300. // stepFinishPartTokensCacheJSON contains the JSON metadata for the struct
  1301. // [StepFinishPartTokensCache]
  1302. type stepFinishPartTokensCacheJSON struct {
  1303. Read apijson.Field
  1304. Write apijson.Field
  1305. raw string
  1306. ExtraFields map[string]apijson.Field
  1307. }
  1308. func (r *StepFinishPartTokensCache) UnmarshalJSON(data []byte) (err error) {
  1309. return apijson.UnmarshalRoot(data, r)
  1310. }
  1311. func (r stepFinishPartTokensCacheJSON) RawJSON() string {
  1312. return r.raw
  1313. }
  1314. type StepFinishPartType string
  1315. const (
  1316. StepFinishPartTypeStepFinish StepFinishPartType = "step-finish"
  1317. )
  1318. func (r StepFinishPartType) IsKnown() bool {
  1319. switch r {
  1320. case StepFinishPartTypeStepFinish:
  1321. return true
  1322. }
  1323. return false
  1324. }
  1325. type StepStartPart struct {
  1326. ID string `json:"id,required"`
  1327. MessageID string `json:"messageID,required"`
  1328. SessionID string `json:"sessionID,required"`
  1329. Type StepStartPartType `json:"type,required"`
  1330. JSON stepStartPartJSON `json:"-"`
  1331. }
  1332. // stepStartPartJSON contains the JSON metadata for the struct [StepStartPart]
  1333. type stepStartPartJSON struct {
  1334. ID apijson.Field
  1335. MessageID apijson.Field
  1336. SessionID apijson.Field
  1337. Type apijson.Field
  1338. raw string
  1339. ExtraFields map[string]apijson.Field
  1340. }
  1341. func (r *StepStartPart) UnmarshalJSON(data []byte) (err error) {
  1342. return apijson.UnmarshalRoot(data, r)
  1343. }
  1344. func (r stepStartPartJSON) RawJSON() string {
  1345. return r.raw
  1346. }
  1347. func (r StepStartPart) implementsPart() {}
  1348. type StepStartPartType string
  1349. const (
  1350. StepStartPartTypeStepStart StepStartPartType = "step-start"
  1351. )
  1352. func (r StepStartPartType) IsKnown() bool {
  1353. switch r {
  1354. case StepStartPartTypeStepStart:
  1355. return true
  1356. }
  1357. return false
  1358. }
  1359. type SymbolSource struct {
  1360. Kind int64 `json:"kind,required"`
  1361. Name string `json:"name,required"`
  1362. Path string `json:"path,required"`
  1363. Range SymbolSourceRange `json:"range,required"`
  1364. Text FilePartSourceText `json:"text,required"`
  1365. Type SymbolSourceType `json:"type,required"`
  1366. JSON symbolSourceJSON `json:"-"`
  1367. }
  1368. // symbolSourceJSON contains the JSON metadata for the struct [SymbolSource]
  1369. type symbolSourceJSON struct {
  1370. Kind apijson.Field
  1371. Name apijson.Field
  1372. Path apijson.Field
  1373. Range apijson.Field
  1374. Text apijson.Field
  1375. Type apijson.Field
  1376. raw string
  1377. ExtraFields map[string]apijson.Field
  1378. }
  1379. func (r *SymbolSource) UnmarshalJSON(data []byte) (err error) {
  1380. return apijson.UnmarshalRoot(data, r)
  1381. }
  1382. func (r symbolSourceJSON) RawJSON() string {
  1383. return r.raw
  1384. }
  1385. func (r SymbolSource) implementsFilePartSource() {}
  1386. type SymbolSourceRange struct {
  1387. End SymbolSourceRangeEnd `json:"end,required"`
  1388. Start SymbolSourceRangeStart `json:"start,required"`
  1389. JSON symbolSourceRangeJSON `json:"-"`
  1390. }
  1391. // symbolSourceRangeJSON contains the JSON metadata for the struct
  1392. // [SymbolSourceRange]
  1393. type symbolSourceRangeJSON struct {
  1394. End apijson.Field
  1395. Start apijson.Field
  1396. raw string
  1397. ExtraFields map[string]apijson.Field
  1398. }
  1399. func (r *SymbolSourceRange) UnmarshalJSON(data []byte) (err error) {
  1400. return apijson.UnmarshalRoot(data, r)
  1401. }
  1402. func (r symbolSourceRangeJSON) RawJSON() string {
  1403. return r.raw
  1404. }
  1405. type SymbolSourceRangeEnd struct {
  1406. Character float64 `json:"character,required"`
  1407. Line float64 `json:"line,required"`
  1408. JSON symbolSourceRangeEndJSON `json:"-"`
  1409. }
  1410. // symbolSourceRangeEndJSON contains the JSON metadata for the struct
  1411. // [SymbolSourceRangeEnd]
  1412. type symbolSourceRangeEndJSON struct {
  1413. Character apijson.Field
  1414. Line apijson.Field
  1415. raw string
  1416. ExtraFields map[string]apijson.Field
  1417. }
  1418. func (r *SymbolSourceRangeEnd) UnmarshalJSON(data []byte) (err error) {
  1419. return apijson.UnmarshalRoot(data, r)
  1420. }
  1421. func (r symbolSourceRangeEndJSON) RawJSON() string {
  1422. return r.raw
  1423. }
  1424. type SymbolSourceRangeStart struct {
  1425. Character float64 `json:"character,required"`
  1426. Line float64 `json:"line,required"`
  1427. JSON symbolSourceRangeStartJSON `json:"-"`
  1428. }
  1429. // symbolSourceRangeStartJSON contains the JSON metadata for the struct
  1430. // [SymbolSourceRangeStart]
  1431. type symbolSourceRangeStartJSON struct {
  1432. Character apijson.Field
  1433. Line apijson.Field
  1434. raw string
  1435. ExtraFields map[string]apijson.Field
  1436. }
  1437. func (r *SymbolSourceRangeStart) UnmarshalJSON(data []byte) (err error) {
  1438. return apijson.UnmarshalRoot(data, r)
  1439. }
  1440. func (r symbolSourceRangeStartJSON) RawJSON() string {
  1441. return r.raw
  1442. }
  1443. type SymbolSourceType string
  1444. const (
  1445. SymbolSourceTypeSymbol SymbolSourceType = "symbol"
  1446. )
  1447. func (r SymbolSourceType) IsKnown() bool {
  1448. switch r {
  1449. case SymbolSourceTypeSymbol:
  1450. return true
  1451. }
  1452. return false
  1453. }
  1454. type SymbolSourceParam struct {
  1455. Kind param.Field[int64] `json:"kind,required"`
  1456. Name param.Field[string] `json:"name,required"`
  1457. Path param.Field[string] `json:"path,required"`
  1458. Range param.Field[SymbolSourceRangeParam] `json:"range,required"`
  1459. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  1460. Type param.Field[SymbolSourceType] `json:"type,required"`
  1461. }
  1462. func (r SymbolSourceParam) MarshalJSON() (data []byte, err error) {
  1463. return apijson.MarshalRoot(r)
  1464. }
  1465. func (r SymbolSourceParam) implementsFilePartSourceUnionParam() {}
  1466. type SymbolSourceRangeParam struct {
  1467. End param.Field[SymbolSourceRangeEndParam] `json:"end,required"`
  1468. Start param.Field[SymbolSourceRangeStartParam] `json:"start,required"`
  1469. }
  1470. func (r SymbolSourceRangeParam) MarshalJSON() (data []byte, err error) {
  1471. return apijson.MarshalRoot(r)
  1472. }
  1473. type SymbolSourceRangeEndParam struct {
  1474. Character param.Field[float64] `json:"character,required"`
  1475. Line param.Field[float64] `json:"line,required"`
  1476. }
  1477. func (r SymbolSourceRangeEndParam) MarshalJSON() (data []byte, err error) {
  1478. return apijson.MarshalRoot(r)
  1479. }
  1480. type SymbolSourceRangeStartParam struct {
  1481. Character param.Field[float64] `json:"character,required"`
  1482. Line param.Field[float64] `json:"line,required"`
  1483. }
  1484. func (r SymbolSourceRangeStartParam) MarshalJSON() (data []byte, err error) {
  1485. return apijson.MarshalRoot(r)
  1486. }
  1487. type TextPart struct {
  1488. ID string `json:"id,required"`
  1489. MessageID string `json:"messageID,required"`
  1490. SessionID string `json:"sessionID,required"`
  1491. Text string `json:"text,required"`
  1492. Type TextPartType `json:"type,required"`
  1493. Synthetic bool `json:"synthetic"`
  1494. Time TextPartTime `json:"time"`
  1495. JSON textPartJSON `json:"-"`
  1496. }
  1497. // textPartJSON contains the JSON metadata for the struct [TextPart]
  1498. type textPartJSON struct {
  1499. ID apijson.Field
  1500. MessageID apijson.Field
  1501. SessionID apijson.Field
  1502. Text apijson.Field
  1503. Type apijson.Field
  1504. Synthetic apijson.Field
  1505. Time apijson.Field
  1506. raw string
  1507. ExtraFields map[string]apijson.Field
  1508. }
  1509. func (r *TextPart) UnmarshalJSON(data []byte) (err error) {
  1510. return apijson.UnmarshalRoot(data, r)
  1511. }
  1512. func (r textPartJSON) RawJSON() string {
  1513. return r.raw
  1514. }
  1515. func (r TextPart) implementsPart() {}
  1516. type TextPartType string
  1517. const (
  1518. TextPartTypeText TextPartType = "text"
  1519. )
  1520. func (r TextPartType) IsKnown() bool {
  1521. switch r {
  1522. case TextPartTypeText:
  1523. return true
  1524. }
  1525. return false
  1526. }
  1527. type TextPartTime struct {
  1528. Start float64 `json:"start,required"`
  1529. End float64 `json:"end"`
  1530. JSON textPartTimeJSON `json:"-"`
  1531. }
  1532. // textPartTimeJSON contains the JSON metadata for the struct [TextPartTime]
  1533. type textPartTimeJSON struct {
  1534. Start apijson.Field
  1535. End apijson.Field
  1536. raw string
  1537. ExtraFields map[string]apijson.Field
  1538. }
  1539. func (r *TextPartTime) UnmarshalJSON(data []byte) (err error) {
  1540. return apijson.UnmarshalRoot(data, r)
  1541. }
  1542. func (r textPartTimeJSON) RawJSON() string {
  1543. return r.raw
  1544. }
  1545. type TextPartInputParam struct {
  1546. Text param.Field[string] `json:"text,required"`
  1547. Type param.Field[TextPartInputType] `json:"type,required"`
  1548. ID param.Field[string] `json:"id"`
  1549. Synthetic param.Field[bool] `json:"synthetic"`
  1550. Time param.Field[TextPartInputTimeParam] `json:"time"`
  1551. }
  1552. func (r TextPartInputParam) MarshalJSON() (data []byte, err error) {
  1553. return apijson.MarshalRoot(r)
  1554. }
  1555. func (r TextPartInputParam) implementsSessionChatParamsPartUnion() {}
  1556. type TextPartInputType string
  1557. const (
  1558. TextPartInputTypeText TextPartInputType = "text"
  1559. )
  1560. func (r TextPartInputType) IsKnown() bool {
  1561. switch r {
  1562. case TextPartInputTypeText:
  1563. return true
  1564. }
  1565. return false
  1566. }
  1567. type TextPartInputTimeParam struct {
  1568. Start param.Field[float64] `json:"start,required"`
  1569. End param.Field[float64] `json:"end"`
  1570. }
  1571. func (r TextPartInputTimeParam) MarshalJSON() (data []byte, err error) {
  1572. return apijson.MarshalRoot(r)
  1573. }
  1574. type ToolPart struct {
  1575. ID string `json:"id,required"`
  1576. CallID string `json:"callID,required"`
  1577. MessageID string `json:"messageID,required"`
  1578. SessionID string `json:"sessionID,required"`
  1579. State ToolPartState `json:"state,required"`
  1580. Tool string `json:"tool,required"`
  1581. Type ToolPartType `json:"type,required"`
  1582. JSON toolPartJSON `json:"-"`
  1583. }
  1584. // toolPartJSON contains the JSON metadata for the struct [ToolPart]
  1585. type toolPartJSON struct {
  1586. ID apijson.Field
  1587. CallID apijson.Field
  1588. MessageID apijson.Field
  1589. SessionID apijson.Field
  1590. State apijson.Field
  1591. Tool apijson.Field
  1592. Type apijson.Field
  1593. raw string
  1594. ExtraFields map[string]apijson.Field
  1595. }
  1596. func (r *ToolPart) UnmarshalJSON(data []byte) (err error) {
  1597. return apijson.UnmarshalRoot(data, r)
  1598. }
  1599. func (r toolPartJSON) RawJSON() string {
  1600. return r.raw
  1601. }
  1602. func (r ToolPart) implementsPart() {}
  1603. type ToolPartState struct {
  1604. Status ToolPartStateStatus `json:"status,required"`
  1605. Error string `json:"error"`
  1606. // This field can have the runtime type of [interface{}], [map[string]interface{}].
  1607. Input interface{} `json:"input"`
  1608. // This field can have the runtime type of [map[string]interface{}].
  1609. Metadata interface{} `json:"metadata"`
  1610. Output string `json:"output"`
  1611. // This field can have the runtime type of [ToolStateRunningTime],
  1612. // [ToolStateCompletedTime], [ToolStateErrorTime].
  1613. Time interface{} `json:"time"`
  1614. Title string `json:"title"`
  1615. JSON toolPartStateJSON `json:"-"`
  1616. union ToolPartStateUnion
  1617. }
  1618. // toolPartStateJSON contains the JSON metadata for the struct [ToolPartState]
  1619. type toolPartStateJSON struct {
  1620. Status apijson.Field
  1621. Error apijson.Field
  1622. Input apijson.Field
  1623. Metadata apijson.Field
  1624. Output apijson.Field
  1625. Time apijson.Field
  1626. Title apijson.Field
  1627. raw string
  1628. ExtraFields map[string]apijson.Field
  1629. }
  1630. func (r toolPartStateJSON) RawJSON() string {
  1631. return r.raw
  1632. }
  1633. func (r *ToolPartState) UnmarshalJSON(data []byte) (err error) {
  1634. *r = ToolPartState{}
  1635. err = apijson.UnmarshalRoot(data, &r.union)
  1636. if err != nil {
  1637. return err
  1638. }
  1639. return apijson.Port(r.union, &r)
  1640. }
  1641. // AsUnion returns a [ToolPartStateUnion] interface which you can cast to the
  1642. // specific types for more type safety.
  1643. //
  1644. // Possible runtime types of the union are [ToolStatePending], [ToolStateRunning],
  1645. // [ToolStateCompleted], [ToolStateError].
  1646. func (r ToolPartState) AsUnion() ToolPartStateUnion {
  1647. return r.union
  1648. }
  1649. // Union satisfied by [ToolStatePending], [ToolStateRunning], [ToolStateCompleted]
  1650. // or [ToolStateError].
  1651. type ToolPartStateUnion interface {
  1652. implementsToolPartState()
  1653. }
  1654. func init() {
  1655. apijson.RegisterUnion(
  1656. reflect.TypeOf((*ToolPartStateUnion)(nil)).Elem(),
  1657. "status",
  1658. apijson.UnionVariant{
  1659. TypeFilter: gjson.JSON,
  1660. Type: reflect.TypeOf(ToolStatePending{}),
  1661. DiscriminatorValue: "pending",
  1662. },
  1663. apijson.UnionVariant{
  1664. TypeFilter: gjson.JSON,
  1665. Type: reflect.TypeOf(ToolStateRunning{}),
  1666. DiscriminatorValue: "running",
  1667. },
  1668. apijson.UnionVariant{
  1669. TypeFilter: gjson.JSON,
  1670. Type: reflect.TypeOf(ToolStateCompleted{}),
  1671. DiscriminatorValue: "completed",
  1672. },
  1673. apijson.UnionVariant{
  1674. TypeFilter: gjson.JSON,
  1675. Type: reflect.TypeOf(ToolStateError{}),
  1676. DiscriminatorValue: "error",
  1677. },
  1678. )
  1679. }
  1680. type ToolPartStateStatus string
  1681. const (
  1682. ToolPartStateStatusPending ToolPartStateStatus = "pending"
  1683. ToolPartStateStatusRunning ToolPartStateStatus = "running"
  1684. ToolPartStateStatusCompleted ToolPartStateStatus = "completed"
  1685. ToolPartStateStatusError ToolPartStateStatus = "error"
  1686. )
  1687. func (r ToolPartStateStatus) IsKnown() bool {
  1688. switch r {
  1689. case ToolPartStateStatusPending, ToolPartStateStatusRunning, ToolPartStateStatusCompleted, ToolPartStateStatusError:
  1690. return true
  1691. }
  1692. return false
  1693. }
  1694. type ToolPartType string
  1695. const (
  1696. ToolPartTypeTool ToolPartType = "tool"
  1697. )
  1698. func (r ToolPartType) IsKnown() bool {
  1699. switch r {
  1700. case ToolPartTypeTool:
  1701. return true
  1702. }
  1703. return false
  1704. }
  1705. type ToolStateCompleted struct {
  1706. Input map[string]interface{} `json:"input,required"`
  1707. Metadata map[string]interface{} `json:"metadata,required"`
  1708. Output string `json:"output,required"`
  1709. Status ToolStateCompletedStatus `json:"status,required"`
  1710. Time ToolStateCompletedTime `json:"time,required"`
  1711. Title string `json:"title,required"`
  1712. JSON toolStateCompletedJSON `json:"-"`
  1713. }
  1714. // toolStateCompletedJSON contains the JSON metadata for the struct
  1715. // [ToolStateCompleted]
  1716. type toolStateCompletedJSON struct {
  1717. Input apijson.Field
  1718. Metadata apijson.Field
  1719. Output apijson.Field
  1720. Status apijson.Field
  1721. Time apijson.Field
  1722. Title apijson.Field
  1723. raw string
  1724. ExtraFields map[string]apijson.Field
  1725. }
  1726. func (r *ToolStateCompleted) UnmarshalJSON(data []byte) (err error) {
  1727. return apijson.UnmarshalRoot(data, r)
  1728. }
  1729. func (r toolStateCompletedJSON) RawJSON() string {
  1730. return r.raw
  1731. }
  1732. func (r ToolStateCompleted) implementsToolPartState() {}
  1733. type ToolStateCompletedStatus string
  1734. const (
  1735. ToolStateCompletedStatusCompleted ToolStateCompletedStatus = "completed"
  1736. )
  1737. func (r ToolStateCompletedStatus) IsKnown() bool {
  1738. switch r {
  1739. case ToolStateCompletedStatusCompleted:
  1740. return true
  1741. }
  1742. return false
  1743. }
  1744. type ToolStateCompletedTime struct {
  1745. End float64 `json:"end,required"`
  1746. Start float64 `json:"start,required"`
  1747. JSON toolStateCompletedTimeJSON `json:"-"`
  1748. }
  1749. // toolStateCompletedTimeJSON contains the JSON metadata for the struct
  1750. // [ToolStateCompletedTime]
  1751. type toolStateCompletedTimeJSON struct {
  1752. End apijson.Field
  1753. Start apijson.Field
  1754. raw string
  1755. ExtraFields map[string]apijson.Field
  1756. }
  1757. func (r *ToolStateCompletedTime) UnmarshalJSON(data []byte) (err error) {
  1758. return apijson.UnmarshalRoot(data, r)
  1759. }
  1760. func (r toolStateCompletedTimeJSON) RawJSON() string {
  1761. return r.raw
  1762. }
  1763. type ToolStateError struct {
  1764. Error string `json:"error,required"`
  1765. Input map[string]interface{} `json:"input,required"`
  1766. Status ToolStateErrorStatus `json:"status,required"`
  1767. Time ToolStateErrorTime `json:"time,required"`
  1768. Metadata map[string]interface{} `json:"metadata"`
  1769. JSON toolStateErrorJSON `json:"-"`
  1770. }
  1771. // toolStateErrorJSON contains the JSON metadata for the struct [ToolStateError]
  1772. type toolStateErrorJSON struct {
  1773. Error apijson.Field
  1774. Input apijson.Field
  1775. Status apijson.Field
  1776. Time apijson.Field
  1777. Metadata apijson.Field
  1778. raw string
  1779. ExtraFields map[string]apijson.Field
  1780. }
  1781. func (r *ToolStateError) UnmarshalJSON(data []byte) (err error) {
  1782. return apijson.UnmarshalRoot(data, r)
  1783. }
  1784. func (r toolStateErrorJSON) RawJSON() string {
  1785. return r.raw
  1786. }
  1787. func (r ToolStateError) implementsToolPartState() {}
  1788. type ToolStateErrorStatus string
  1789. const (
  1790. ToolStateErrorStatusError ToolStateErrorStatus = "error"
  1791. )
  1792. func (r ToolStateErrorStatus) IsKnown() bool {
  1793. switch r {
  1794. case ToolStateErrorStatusError:
  1795. return true
  1796. }
  1797. return false
  1798. }
  1799. type ToolStateErrorTime struct {
  1800. End float64 `json:"end,required"`
  1801. Start float64 `json:"start,required"`
  1802. JSON toolStateErrorTimeJSON `json:"-"`
  1803. }
  1804. // toolStateErrorTimeJSON contains the JSON metadata for the struct
  1805. // [ToolStateErrorTime]
  1806. type toolStateErrorTimeJSON struct {
  1807. End apijson.Field
  1808. Start apijson.Field
  1809. raw string
  1810. ExtraFields map[string]apijson.Field
  1811. }
  1812. func (r *ToolStateErrorTime) UnmarshalJSON(data []byte) (err error) {
  1813. return apijson.UnmarshalRoot(data, r)
  1814. }
  1815. func (r toolStateErrorTimeJSON) RawJSON() string {
  1816. return r.raw
  1817. }
  1818. type ToolStatePending struct {
  1819. Status ToolStatePendingStatus `json:"status,required"`
  1820. JSON toolStatePendingJSON `json:"-"`
  1821. }
  1822. // toolStatePendingJSON contains the JSON metadata for the struct
  1823. // [ToolStatePending]
  1824. type toolStatePendingJSON struct {
  1825. Status apijson.Field
  1826. raw string
  1827. ExtraFields map[string]apijson.Field
  1828. }
  1829. func (r *ToolStatePending) UnmarshalJSON(data []byte) (err error) {
  1830. return apijson.UnmarshalRoot(data, r)
  1831. }
  1832. func (r toolStatePendingJSON) RawJSON() string {
  1833. return r.raw
  1834. }
  1835. func (r ToolStatePending) implementsToolPartState() {}
  1836. type ToolStatePendingStatus string
  1837. const (
  1838. ToolStatePendingStatusPending ToolStatePendingStatus = "pending"
  1839. )
  1840. func (r ToolStatePendingStatus) IsKnown() bool {
  1841. switch r {
  1842. case ToolStatePendingStatusPending:
  1843. return true
  1844. }
  1845. return false
  1846. }
  1847. type ToolStateRunning struct {
  1848. Status ToolStateRunningStatus `json:"status,required"`
  1849. Time ToolStateRunningTime `json:"time,required"`
  1850. Input interface{} `json:"input"`
  1851. Metadata map[string]interface{} `json:"metadata"`
  1852. Title string `json:"title"`
  1853. JSON toolStateRunningJSON `json:"-"`
  1854. }
  1855. // toolStateRunningJSON contains the JSON metadata for the struct
  1856. // [ToolStateRunning]
  1857. type toolStateRunningJSON struct {
  1858. Status apijson.Field
  1859. Time apijson.Field
  1860. Input apijson.Field
  1861. Metadata apijson.Field
  1862. Title apijson.Field
  1863. raw string
  1864. ExtraFields map[string]apijson.Field
  1865. }
  1866. func (r *ToolStateRunning) UnmarshalJSON(data []byte) (err error) {
  1867. return apijson.UnmarshalRoot(data, r)
  1868. }
  1869. func (r toolStateRunningJSON) RawJSON() string {
  1870. return r.raw
  1871. }
  1872. func (r ToolStateRunning) implementsToolPartState() {}
  1873. type ToolStateRunningStatus string
  1874. const (
  1875. ToolStateRunningStatusRunning ToolStateRunningStatus = "running"
  1876. )
  1877. func (r ToolStateRunningStatus) IsKnown() bool {
  1878. switch r {
  1879. case ToolStateRunningStatusRunning:
  1880. return true
  1881. }
  1882. return false
  1883. }
  1884. type ToolStateRunningTime struct {
  1885. Start float64 `json:"start,required"`
  1886. JSON toolStateRunningTimeJSON `json:"-"`
  1887. }
  1888. // toolStateRunningTimeJSON contains the JSON metadata for the struct
  1889. // [ToolStateRunningTime]
  1890. type toolStateRunningTimeJSON struct {
  1891. Start apijson.Field
  1892. raw string
  1893. ExtraFields map[string]apijson.Field
  1894. }
  1895. func (r *ToolStateRunningTime) UnmarshalJSON(data []byte) (err error) {
  1896. return apijson.UnmarshalRoot(data, r)
  1897. }
  1898. func (r toolStateRunningTimeJSON) RawJSON() string {
  1899. return r.raw
  1900. }
  1901. type UserMessage struct {
  1902. ID string `json:"id,required"`
  1903. Role UserMessageRole `json:"role,required"`
  1904. SessionID string `json:"sessionID,required"`
  1905. Time UserMessageTime `json:"time,required"`
  1906. JSON userMessageJSON `json:"-"`
  1907. }
  1908. // userMessageJSON contains the JSON metadata for the struct [UserMessage]
  1909. type userMessageJSON struct {
  1910. ID apijson.Field
  1911. Role apijson.Field
  1912. SessionID apijson.Field
  1913. Time apijson.Field
  1914. raw string
  1915. ExtraFields map[string]apijson.Field
  1916. }
  1917. func (r *UserMessage) UnmarshalJSON(data []byte) (err error) {
  1918. return apijson.UnmarshalRoot(data, r)
  1919. }
  1920. func (r userMessageJSON) RawJSON() string {
  1921. return r.raw
  1922. }
  1923. func (r UserMessage) implementsMessage() {}
  1924. type UserMessageRole string
  1925. const (
  1926. UserMessageRoleUser UserMessageRole = "user"
  1927. )
  1928. func (r UserMessageRole) IsKnown() bool {
  1929. switch r {
  1930. case UserMessageRoleUser:
  1931. return true
  1932. }
  1933. return false
  1934. }
  1935. type UserMessageTime struct {
  1936. Created float64 `json:"created,required"`
  1937. JSON userMessageTimeJSON `json:"-"`
  1938. }
  1939. // userMessageTimeJSON contains the JSON metadata for the struct [UserMessageTime]
  1940. type userMessageTimeJSON struct {
  1941. Created apijson.Field
  1942. raw string
  1943. ExtraFields map[string]apijson.Field
  1944. }
  1945. func (r *UserMessageTime) UnmarshalJSON(data []byte) (err error) {
  1946. return apijson.UnmarshalRoot(data, r)
  1947. }
  1948. func (r userMessageTimeJSON) RawJSON() string {
  1949. return r.raw
  1950. }
  1951. type SessionChatResponse struct {
  1952. Info AssistantMessage `json:"info,required"`
  1953. Parts []Part `json:"parts,required"`
  1954. JSON sessionChatResponseJSON `json:"-"`
  1955. }
  1956. // sessionChatResponseJSON contains the JSON metadata for the struct
  1957. // [SessionChatResponse]
  1958. type sessionChatResponseJSON struct {
  1959. Info apijson.Field
  1960. Parts apijson.Field
  1961. raw string
  1962. ExtraFields map[string]apijson.Field
  1963. }
  1964. func (r *SessionChatResponse) UnmarshalJSON(data []byte) (err error) {
  1965. return apijson.UnmarshalRoot(data, r)
  1966. }
  1967. func (r sessionChatResponseJSON) RawJSON() string {
  1968. return r.raw
  1969. }
  1970. type SessionCommandResponse struct {
  1971. Info AssistantMessage `json:"info,required"`
  1972. Parts []Part `json:"parts,required"`
  1973. JSON sessionCommandResponseJSON `json:"-"`
  1974. }
  1975. // sessionCommandResponseJSON contains the JSON metadata for the struct
  1976. // [SessionCommandResponse]
  1977. type sessionCommandResponseJSON struct {
  1978. Info apijson.Field
  1979. Parts apijson.Field
  1980. raw string
  1981. ExtraFields map[string]apijson.Field
  1982. }
  1983. func (r *SessionCommandResponse) UnmarshalJSON(data []byte) (err error) {
  1984. return apijson.UnmarshalRoot(data, r)
  1985. }
  1986. func (r sessionCommandResponseJSON) RawJSON() string {
  1987. return r.raw
  1988. }
  1989. type SessionMessageResponse struct {
  1990. Info Message `json:"info,required"`
  1991. Parts []Part `json:"parts,required"`
  1992. JSON sessionMessageResponseJSON `json:"-"`
  1993. }
  1994. // sessionMessageResponseJSON contains the JSON metadata for the struct
  1995. // [SessionMessageResponse]
  1996. type sessionMessageResponseJSON struct {
  1997. Info apijson.Field
  1998. Parts apijson.Field
  1999. raw string
  2000. ExtraFields map[string]apijson.Field
  2001. }
  2002. func (r *SessionMessageResponse) UnmarshalJSON(data []byte) (err error) {
  2003. return apijson.UnmarshalRoot(data, r)
  2004. }
  2005. func (r sessionMessageResponseJSON) RawJSON() string {
  2006. return r.raw
  2007. }
  2008. type SessionMessagesResponse struct {
  2009. Info Message `json:"info,required"`
  2010. Parts []Part `json:"parts,required"`
  2011. JSON sessionMessagesResponseJSON `json:"-"`
  2012. }
  2013. // sessionMessagesResponseJSON contains the JSON metadata for the struct
  2014. // [SessionMessagesResponse]
  2015. type sessionMessagesResponseJSON struct {
  2016. Info apijson.Field
  2017. Parts apijson.Field
  2018. raw string
  2019. ExtraFields map[string]apijson.Field
  2020. }
  2021. func (r *SessionMessagesResponse) UnmarshalJSON(data []byte) (err error) {
  2022. return apijson.UnmarshalRoot(data, r)
  2023. }
  2024. func (r sessionMessagesResponseJSON) RawJSON() string {
  2025. return r.raw
  2026. }
  2027. type SessionNewParams struct {
  2028. ParentID param.Field[string] `json:"parentID"`
  2029. Title param.Field[string] `json:"title"`
  2030. }
  2031. func (r SessionNewParams) MarshalJSON() (data []byte, err error) {
  2032. return apijson.MarshalRoot(r)
  2033. }
  2034. type SessionUpdateParams struct {
  2035. Title param.Field[string] `json:"title"`
  2036. }
  2037. func (r SessionUpdateParams) MarshalJSON() (data []byte, err error) {
  2038. return apijson.MarshalRoot(r)
  2039. }
  2040. type SessionChatParams struct {
  2041. ModelID param.Field[string] `json:"modelID,required"`
  2042. Parts param.Field[[]SessionChatParamsPartUnion] `json:"parts,required"`
  2043. ProviderID param.Field[string] `json:"providerID,required"`
  2044. Agent param.Field[string] `json:"agent"`
  2045. MessageID param.Field[string] `json:"messageID"`
  2046. System param.Field[string] `json:"system"`
  2047. Tools param.Field[map[string]bool] `json:"tools"`
  2048. }
  2049. func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
  2050. return apijson.MarshalRoot(r)
  2051. }
  2052. type SessionChatParamsPart struct {
  2053. Type param.Field[SessionChatParamsPartsType] `json:"type,required"`
  2054. ID param.Field[string] `json:"id"`
  2055. Filename param.Field[string] `json:"filename"`
  2056. Mime param.Field[string] `json:"mime"`
  2057. Name param.Field[string] `json:"name"`
  2058. Source param.Field[interface{}] `json:"source"`
  2059. Synthetic param.Field[bool] `json:"synthetic"`
  2060. Text param.Field[string] `json:"text"`
  2061. Time param.Field[interface{}] `json:"time"`
  2062. URL param.Field[string] `json:"url"`
  2063. }
  2064. func (r SessionChatParamsPart) MarshalJSON() (data []byte, err error) {
  2065. return apijson.MarshalRoot(r)
  2066. }
  2067. func (r SessionChatParamsPart) implementsSessionChatParamsPartUnion() {}
  2068. // Satisfied by [TextPartInputParam], [FilePartInputParam], [AgentPartInputParam],
  2069. // [SessionChatParamsPart].
  2070. type SessionChatParamsPartUnion interface {
  2071. implementsSessionChatParamsPartUnion()
  2072. }
  2073. type SessionChatParamsPartsType string
  2074. const (
  2075. SessionChatParamsPartsTypeText SessionChatParamsPartsType = "text"
  2076. SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
  2077. SessionChatParamsPartsTypeAgent SessionChatParamsPartsType = "agent"
  2078. )
  2079. func (r SessionChatParamsPartsType) IsKnown() bool {
  2080. switch r {
  2081. case SessionChatParamsPartsTypeText, SessionChatParamsPartsTypeFile, SessionChatParamsPartsTypeAgent:
  2082. return true
  2083. }
  2084. return false
  2085. }
  2086. type SessionCommandParams struct {
  2087. Arguments param.Field[string] `json:"arguments,required"`
  2088. Command param.Field[string] `json:"command,required"`
  2089. Agent param.Field[string] `json:"agent"`
  2090. MessageID param.Field[string] `json:"messageID"`
  2091. Model param.Field[string] `json:"model"`
  2092. }
  2093. func (r SessionCommandParams) MarshalJSON() (data []byte, err error) {
  2094. return apijson.MarshalRoot(r)
  2095. }
  2096. type SessionInitParams struct {
  2097. MessageID param.Field[string] `json:"messageID,required"`
  2098. ModelID param.Field[string] `json:"modelID,required"`
  2099. ProviderID param.Field[string] `json:"providerID,required"`
  2100. }
  2101. func (r SessionInitParams) MarshalJSON() (data []byte, err error) {
  2102. return apijson.MarshalRoot(r)
  2103. }
  2104. type SessionRevertParams struct {
  2105. MessageID param.Field[string] `json:"messageID,required"`
  2106. PartID param.Field[string] `json:"partID"`
  2107. }
  2108. func (r SessionRevertParams) MarshalJSON() (data []byte, err error) {
  2109. return apijson.MarshalRoot(r)
  2110. }
  2111. type SessionShellParams struct {
  2112. Agent param.Field[string] `json:"agent,required"`
  2113. Command param.Field[string] `json:"command,required"`
  2114. }
  2115. func (r SessionShellParams) MarshalJSON() (data []byte, err error) {
  2116. return apijson.MarshalRoot(r)
  2117. }
  2118. type SessionSummarizeParams struct {
  2119. ModelID param.Field[string] `json:"modelID,required"`
  2120. ProviderID param.Field[string] `json:"providerID,required"`
  2121. }
  2122. func (r SessionSummarizeParams) MarshalJSON() (data []byte, err error) {
  2123. return apijson.MarshalRoot(r)
  2124. }