session.go 66 KB

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