session.go 87 KB

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