session.go 77 KB

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