session.go 67 KB

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