session.go 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710
  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. JSON sessionTimeJSON `json:"-"`
  1163. }
  1164. // sessionTimeJSON contains the JSON metadata for the struct [SessionTime]
  1165. type sessionTimeJSON struct {
  1166. Created apijson.Field
  1167. Updated apijson.Field
  1168. raw string
  1169. ExtraFields map[string]apijson.Field
  1170. }
  1171. func (r *SessionTime) UnmarshalJSON(data []byte) (err error) {
  1172. return apijson.UnmarshalRoot(data, r)
  1173. }
  1174. func (r sessionTimeJSON) RawJSON() string {
  1175. return r.raw
  1176. }
  1177. type SessionRevert struct {
  1178. MessageID string `json:"messageID,required"`
  1179. Diff string `json:"diff"`
  1180. PartID string `json:"partID"`
  1181. Snapshot string `json:"snapshot"`
  1182. JSON sessionRevertJSON `json:"-"`
  1183. }
  1184. // sessionRevertJSON contains the JSON metadata for the struct [SessionRevert]
  1185. type sessionRevertJSON struct {
  1186. MessageID apijson.Field
  1187. Diff apijson.Field
  1188. PartID apijson.Field
  1189. Snapshot apijson.Field
  1190. raw string
  1191. ExtraFields map[string]apijson.Field
  1192. }
  1193. func (r *SessionRevert) UnmarshalJSON(data []byte) (err error) {
  1194. return apijson.UnmarshalRoot(data, r)
  1195. }
  1196. func (r sessionRevertJSON) RawJSON() string {
  1197. return r.raw
  1198. }
  1199. type SessionShare struct {
  1200. URL string `json:"url,required"`
  1201. JSON sessionShareJSON `json:"-"`
  1202. }
  1203. // sessionShareJSON contains the JSON metadata for the struct [SessionShare]
  1204. type sessionShareJSON struct {
  1205. URL apijson.Field
  1206. raw string
  1207. ExtraFields map[string]apijson.Field
  1208. }
  1209. func (r *SessionShare) UnmarshalJSON(data []byte) (err error) {
  1210. return apijson.UnmarshalRoot(data, r)
  1211. }
  1212. func (r sessionShareJSON) RawJSON() string {
  1213. return r.raw
  1214. }
  1215. type SnapshotPart struct {
  1216. ID string `json:"id,required"`
  1217. MessageID string `json:"messageID,required"`
  1218. SessionID string `json:"sessionID,required"`
  1219. Snapshot string `json:"snapshot,required"`
  1220. Type SnapshotPartType `json:"type,required"`
  1221. JSON snapshotPartJSON `json:"-"`
  1222. }
  1223. // snapshotPartJSON contains the JSON metadata for the struct [SnapshotPart]
  1224. type snapshotPartJSON struct {
  1225. ID apijson.Field
  1226. MessageID apijson.Field
  1227. SessionID apijson.Field
  1228. Snapshot apijson.Field
  1229. Type apijson.Field
  1230. raw string
  1231. ExtraFields map[string]apijson.Field
  1232. }
  1233. func (r *SnapshotPart) UnmarshalJSON(data []byte) (err error) {
  1234. return apijson.UnmarshalRoot(data, r)
  1235. }
  1236. func (r snapshotPartJSON) RawJSON() string {
  1237. return r.raw
  1238. }
  1239. func (r SnapshotPart) implementsPart() {}
  1240. type SnapshotPartType string
  1241. const (
  1242. SnapshotPartTypeSnapshot SnapshotPartType = "snapshot"
  1243. )
  1244. func (r SnapshotPartType) IsKnown() bool {
  1245. switch r {
  1246. case SnapshotPartTypeSnapshot:
  1247. return true
  1248. }
  1249. return false
  1250. }
  1251. type StepFinishPart struct {
  1252. ID string `json:"id,required"`
  1253. Cost float64 `json:"cost,required"`
  1254. MessageID string `json:"messageID,required"`
  1255. SessionID string `json:"sessionID,required"`
  1256. Tokens StepFinishPartTokens `json:"tokens,required"`
  1257. Type StepFinishPartType `json:"type,required"`
  1258. JSON stepFinishPartJSON `json:"-"`
  1259. }
  1260. // stepFinishPartJSON contains the JSON metadata for the struct [StepFinishPart]
  1261. type stepFinishPartJSON struct {
  1262. ID apijson.Field
  1263. Cost apijson.Field
  1264. MessageID apijson.Field
  1265. SessionID apijson.Field
  1266. Tokens apijson.Field
  1267. Type apijson.Field
  1268. raw string
  1269. ExtraFields map[string]apijson.Field
  1270. }
  1271. func (r *StepFinishPart) UnmarshalJSON(data []byte) (err error) {
  1272. return apijson.UnmarshalRoot(data, r)
  1273. }
  1274. func (r stepFinishPartJSON) RawJSON() string {
  1275. return r.raw
  1276. }
  1277. func (r StepFinishPart) implementsPart() {}
  1278. type StepFinishPartTokens struct {
  1279. Cache StepFinishPartTokensCache `json:"cache,required"`
  1280. Input float64 `json:"input,required"`
  1281. Output float64 `json:"output,required"`
  1282. Reasoning float64 `json:"reasoning,required"`
  1283. JSON stepFinishPartTokensJSON `json:"-"`
  1284. }
  1285. // stepFinishPartTokensJSON contains the JSON metadata for the struct
  1286. // [StepFinishPartTokens]
  1287. type stepFinishPartTokensJSON struct {
  1288. Cache apijson.Field
  1289. Input apijson.Field
  1290. Output apijson.Field
  1291. Reasoning apijson.Field
  1292. raw string
  1293. ExtraFields map[string]apijson.Field
  1294. }
  1295. func (r *StepFinishPartTokens) UnmarshalJSON(data []byte) (err error) {
  1296. return apijson.UnmarshalRoot(data, r)
  1297. }
  1298. func (r stepFinishPartTokensJSON) RawJSON() string {
  1299. return r.raw
  1300. }
  1301. type StepFinishPartTokensCache struct {
  1302. Read float64 `json:"read,required"`
  1303. Write float64 `json:"write,required"`
  1304. JSON stepFinishPartTokensCacheJSON `json:"-"`
  1305. }
  1306. // stepFinishPartTokensCacheJSON contains the JSON metadata for the struct
  1307. // [StepFinishPartTokensCache]
  1308. type stepFinishPartTokensCacheJSON struct {
  1309. Read apijson.Field
  1310. Write apijson.Field
  1311. raw string
  1312. ExtraFields map[string]apijson.Field
  1313. }
  1314. func (r *StepFinishPartTokensCache) UnmarshalJSON(data []byte) (err error) {
  1315. return apijson.UnmarshalRoot(data, r)
  1316. }
  1317. func (r stepFinishPartTokensCacheJSON) RawJSON() string {
  1318. return r.raw
  1319. }
  1320. type StepFinishPartType string
  1321. const (
  1322. StepFinishPartTypeStepFinish StepFinishPartType = "step-finish"
  1323. )
  1324. func (r StepFinishPartType) IsKnown() bool {
  1325. switch r {
  1326. case StepFinishPartTypeStepFinish:
  1327. return true
  1328. }
  1329. return false
  1330. }
  1331. type StepStartPart struct {
  1332. ID string `json:"id,required"`
  1333. MessageID string `json:"messageID,required"`
  1334. SessionID string `json:"sessionID,required"`
  1335. Type StepStartPartType `json:"type,required"`
  1336. JSON stepStartPartJSON `json:"-"`
  1337. }
  1338. // stepStartPartJSON contains the JSON metadata for the struct [StepStartPart]
  1339. type stepStartPartJSON struct {
  1340. ID apijson.Field
  1341. MessageID apijson.Field
  1342. SessionID apijson.Field
  1343. Type apijson.Field
  1344. raw string
  1345. ExtraFields map[string]apijson.Field
  1346. }
  1347. func (r *StepStartPart) UnmarshalJSON(data []byte) (err error) {
  1348. return apijson.UnmarshalRoot(data, r)
  1349. }
  1350. func (r stepStartPartJSON) RawJSON() string {
  1351. return r.raw
  1352. }
  1353. func (r StepStartPart) implementsPart() {}
  1354. type StepStartPartType string
  1355. const (
  1356. StepStartPartTypeStepStart StepStartPartType = "step-start"
  1357. )
  1358. func (r StepStartPartType) IsKnown() bool {
  1359. switch r {
  1360. case StepStartPartTypeStepStart:
  1361. return true
  1362. }
  1363. return false
  1364. }
  1365. type SymbolSource struct {
  1366. Kind int64 `json:"kind,required"`
  1367. Name string `json:"name,required"`
  1368. Path string `json:"path,required"`
  1369. Range SymbolSourceRange `json:"range,required"`
  1370. Text FilePartSourceText `json:"text,required"`
  1371. Type SymbolSourceType `json:"type,required"`
  1372. JSON symbolSourceJSON `json:"-"`
  1373. }
  1374. // symbolSourceJSON contains the JSON metadata for the struct [SymbolSource]
  1375. type symbolSourceJSON struct {
  1376. Kind apijson.Field
  1377. Name apijson.Field
  1378. Path apijson.Field
  1379. Range apijson.Field
  1380. Text apijson.Field
  1381. Type apijson.Field
  1382. raw string
  1383. ExtraFields map[string]apijson.Field
  1384. }
  1385. func (r *SymbolSource) UnmarshalJSON(data []byte) (err error) {
  1386. return apijson.UnmarshalRoot(data, r)
  1387. }
  1388. func (r symbolSourceJSON) RawJSON() string {
  1389. return r.raw
  1390. }
  1391. func (r SymbolSource) implementsFilePartSource() {}
  1392. type SymbolSourceRange struct {
  1393. End SymbolSourceRangeEnd `json:"end,required"`
  1394. Start SymbolSourceRangeStart `json:"start,required"`
  1395. JSON symbolSourceRangeJSON `json:"-"`
  1396. }
  1397. // symbolSourceRangeJSON contains the JSON metadata for the struct
  1398. // [SymbolSourceRange]
  1399. type symbolSourceRangeJSON struct {
  1400. End apijson.Field
  1401. Start apijson.Field
  1402. raw string
  1403. ExtraFields map[string]apijson.Field
  1404. }
  1405. func (r *SymbolSourceRange) UnmarshalJSON(data []byte) (err error) {
  1406. return apijson.UnmarshalRoot(data, r)
  1407. }
  1408. func (r symbolSourceRangeJSON) RawJSON() string {
  1409. return r.raw
  1410. }
  1411. type SymbolSourceRangeEnd struct {
  1412. Character float64 `json:"character,required"`
  1413. Line float64 `json:"line,required"`
  1414. JSON symbolSourceRangeEndJSON `json:"-"`
  1415. }
  1416. // symbolSourceRangeEndJSON contains the JSON metadata for the struct
  1417. // [SymbolSourceRangeEnd]
  1418. type symbolSourceRangeEndJSON struct {
  1419. Character apijson.Field
  1420. Line apijson.Field
  1421. raw string
  1422. ExtraFields map[string]apijson.Field
  1423. }
  1424. func (r *SymbolSourceRangeEnd) UnmarshalJSON(data []byte) (err error) {
  1425. return apijson.UnmarshalRoot(data, r)
  1426. }
  1427. func (r symbolSourceRangeEndJSON) RawJSON() string {
  1428. return r.raw
  1429. }
  1430. type SymbolSourceRangeStart struct {
  1431. Character float64 `json:"character,required"`
  1432. Line float64 `json:"line,required"`
  1433. JSON symbolSourceRangeStartJSON `json:"-"`
  1434. }
  1435. // symbolSourceRangeStartJSON contains the JSON metadata for the struct
  1436. // [SymbolSourceRangeStart]
  1437. type symbolSourceRangeStartJSON struct {
  1438. Character apijson.Field
  1439. Line apijson.Field
  1440. raw string
  1441. ExtraFields map[string]apijson.Field
  1442. }
  1443. func (r *SymbolSourceRangeStart) UnmarshalJSON(data []byte) (err error) {
  1444. return apijson.UnmarshalRoot(data, r)
  1445. }
  1446. func (r symbolSourceRangeStartJSON) RawJSON() string {
  1447. return r.raw
  1448. }
  1449. type SymbolSourceType string
  1450. const (
  1451. SymbolSourceTypeSymbol SymbolSourceType = "symbol"
  1452. )
  1453. func (r SymbolSourceType) IsKnown() bool {
  1454. switch r {
  1455. case SymbolSourceTypeSymbol:
  1456. return true
  1457. }
  1458. return false
  1459. }
  1460. type SymbolSourceParam struct {
  1461. Kind param.Field[int64] `json:"kind,required"`
  1462. Name param.Field[string] `json:"name,required"`
  1463. Path param.Field[string] `json:"path,required"`
  1464. Range param.Field[SymbolSourceRangeParam] `json:"range,required"`
  1465. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  1466. Type param.Field[SymbolSourceType] `json:"type,required"`
  1467. }
  1468. func (r SymbolSourceParam) MarshalJSON() (data []byte, err error) {
  1469. return apijson.MarshalRoot(r)
  1470. }
  1471. func (r SymbolSourceParam) implementsFilePartSourceUnionParam() {}
  1472. type SymbolSourceRangeParam struct {
  1473. End param.Field[SymbolSourceRangeEndParam] `json:"end,required"`
  1474. Start param.Field[SymbolSourceRangeStartParam] `json:"start,required"`
  1475. }
  1476. func (r SymbolSourceRangeParam) MarshalJSON() (data []byte, err error) {
  1477. return apijson.MarshalRoot(r)
  1478. }
  1479. type SymbolSourceRangeEndParam struct {
  1480. Character param.Field[float64] `json:"character,required"`
  1481. Line param.Field[float64] `json:"line,required"`
  1482. }
  1483. func (r SymbolSourceRangeEndParam) MarshalJSON() (data []byte, err error) {
  1484. return apijson.MarshalRoot(r)
  1485. }
  1486. type SymbolSourceRangeStartParam struct {
  1487. Character param.Field[float64] `json:"character,required"`
  1488. Line param.Field[float64] `json:"line,required"`
  1489. }
  1490. func (r SymbolSourceRangeStartParam) MarshalJSON() (data []byte, err error) {
  1491. return apijson.MarshalRoot(r)
  1492. }
  1493. type TextPart struct {
  1494. ID string `json:"id,required"`
  1495. MessageID string `json:"messageID,required"`
  1496. SessionID string `json:"sessionID,required"`
  1497. Text string `json:"text,required"`
  1498. Type TextPartType `json:"type,required"`
  1499. Synthetic bool `json:"synthetic"`
  1500. Time TextPartTime `json:"time"`
  1501. JSON textPartJSON `json:"-"`
  1502. }
  1503. // textPartJSON contains the JSON metadata for the struct [TextPart]
  1504. type textPartJSON struct {
  1505. ID apijson.Field
  1506. MessageID apijson.Field
  1507. SessionID apijson.Field
  1508. Text apijson.Field
  1509. Type apijson.Field
  1510. Synthetic apijson.Field
  1511. Time apijson.Field
  1512. raw string
  1513. ExtraFields map[string]apijson.Field
  1514. }
  1515. func (r *TextPart) UnmarshalJSON(data []byte) (err error) {
  1516. return apijson.UnmarshalRoot(data, r)
  1517. }
  1518. func (r textPartJSON) RawJSON() string {
  1519. return r.raw
  1520. }
  1521. func (r TextPart) implementsPart() {}
  1522. type TextPartType string
  1523. const (
  1524. TextPartTypeText TextPartType = "text"
  1525. )
  1526. func (r TextPartType) IsKnown() bool {
  1527. switch r {
  1528. case TextPartTypeText:
  1529. return true
  1530. }
  1531. return false
  1532. }
  1533. type TextPartTime struct {
  1534. Start float64 `json:"start,required"`
  1535. End float64 `json:"end"`
  1536. JSON textPartTimeJSON `json:"-"`
  1537. }
  1538. // textPartTimeJSON contains the JSON metadata for the struct [TextPartTime]
  1539. type textPartTimeJSON struct {
  1540. Start apijson.Field
  1541. End apijson.Field
  1542. raw string
  1543. ExtraFields map[string]apijson.Field
  1544. }
  1545. func (r *TextPartTime) UnmarshalJSON(data []byte) (err error) {
  1546. return apijson.UnmarshalRoot(data, r)
  1547. }
  1548. func (r textPartTimeJSON) RawJSON() string {
  1549. return r.raw
  1550. }
  1551. type TextPartInputParam struct {
  1552. Text param.Field[string] `json:"text,required"`
  1553. Type param.Field[TextPartInputType] `json:"type,required"`
  1554. ID param.Field[string] `json:"id"`
  1555. Synthetic param.Field[bool] `json:"synthetic"`
  1556. Time param.Field[TextPartInputTimeParam] `json:"time"`
  1557. }
  1558. func (r TextPartInputParam) MarshalJSON() (data []byte, err error) {
  1559. return apijson.MarshalRoot(r)
  1560. }
  1561. func (r TextPartInputParam) implementsSessionPromptParamsPartUnion() {}
  1562. type TextPartInputType string
  1563. const (
  1564. TextPartInputTypeText TextPartInputType = "text"
  1565. )
  1566. func (r TextPartInputType) IsKnown() bool {
  1567. switch r {
  1568. case TextPartInputTypeText:
  1569. return true
  1570. }
  1571. return false
  1572. }
  1573. type TextPartInputTimeParam struct {
  1574. Start param.Field[float64] `json:"start,required"`
  1575. End param.Field[float64] `json:"end"`
  1576. }
  1577. func (r TextPartInputTimeParam) MarshalJSON() (data []byte, err error) {
  1578. return apijson.MarshalRoot(r)
  1579. }
  1580. type ToolPart struct {
  1581. ID string `json:"id,required"`
  1582. CallID string `json:"callID,required"`
  1583. MessageID string `json:"messageID,required"`
  1584. SessionID string `json:"sessionID,required"`
  1585. State ToolPartState `json:"state,required"`
  1586. Tool string `json:"tool,required"`
  1587. Type ToolPartType `json:"type,required"`
  1588. JSON toolPartJSON `json:"-"`
  1589. }
  1590. // toolPartJSON contains the JSON metadata for the struct [ToolPart]
  1591. type toolPartJSON struct {
  1592. ID apijson.Field
  1593. CallID apijson.Field
  1594. MessageID apijson.Field
  1595. SessionID apijson.Field
  1596. State apijson.Field
  1597. Tool apijson.Field
  1598. Type apijson.Field
  1599. raw string
  1600. ExtraFields map[string]apijson.Field
  1601. }
  1602. func (r *ToolPart) UnmarshalJSON(data []byte) (err error) {
  1603. return apijson.UnmarshalRoot(data, r)
  1604. }
  1605. func (r toolPartJSON) RawJSON() string {
  1606. return r.raw
  1607. }
  1608. func (r ToolPart) implementsPart() {}
  1609. type ToolPartState struct {
  1610. Status ToolPartStateStatus `json:"status,required"`
  1611. Error string `json:"error"`
  1612. // This field can have the runtime type of [interface{}], [map[string]interface{}].
  1613. Input interface{} `json:"input"`
  1614. // This field can have the runtime type of [map[string]interface{}].
  1615. Metadata interface{} `json:"metadata"`
  1616. Output string `json:"output"`
  1617. // This field can have the runtime type of [ToolStateRunningTime],
  1618. // [ToolStateCompletedTime], [ToolStateErrorTime].
  1619. Time interface{} `json:"time"`
  1620. Title string `json:"title"`
  1621. JSON toolPartStateJSON `json:"-"`
  1622. union ToolPartStateUnion
  1623. }
  1624. // toolPartStateJSON contains the JSON metadata for the struct [ToolPartState]
  1625. type toolPartStateJSON struct {
  1626. Status apijson.Field
  1627. Error apijson.Field
  1628. Input apijson.Field
  1629. Metadata apijson.Field
  1630. Output apijson.Field
  1631. Time apijson.Field
  1632. Title apijson.Field
  1633. raw string
  1634. ExtraFields map[string]apijson.Field
  1635. }
  1636. func (r toolPartStateJSON) RawJSON() string {
  1637. return r.raw
  1638. }
  1639. func (r *ToolPartState) UnmarshalJSON(data []byte) (err error) {
  1640. *r = ToolPartState{}
  1641. err = apijson.UnmarshalRoot(data, &r.union)
  1642. if err != nil {
  1643. return err
  1644. }
  1645. return apijson.Port(r.union, &r)
  1646. }
  1647. // AsUnion returns a [ToolPartStateUnion] interface which you can cast to the
  1648. // specific types for more type safety.
  1649. //
  1650. // Possible runtime types of the union are [ToolStatePending], [ToolStateRunning],
  1651. // [ToolStateCompleted], [ToolStateError].
  1652. func (r ToolPartState) AsUnion() ToolPartStateUnion {
  1653. return r.union
  1654. }
  1655. // Union satisfied by [ToolStatePending], [ToolStateRunning], [ToolStateCompleted]
  1656. // or [ToolStateError].
  1657. type ToolPartStateUnion interface {
  1658. implementsToolPartState()
  1659. }
  1660. func init() {
  1661. apijson.RegisterUnion(
  1662. reflect.TypeOf((*ToolPartStateUnion)(nil)).Elem(),
  1663. "status",
  1664. apijson.UnionVariant{
  1665. TypeFilter: gjson.JSON,
  1666. Type: reflect.TypeOf(ToolStatePending{}),
  1667. DiscriminatorValue: "pending",
  1668. },
  1669. apijson.UnionVariant{
  1670. TypeFilter: gjson.JSON,
  1671. Type: reflect.TypeOf(ToolStateRunning{}),
  1672. DiscriminatorValue: "running",
  1673. },
  1674. apijson.UnionVariant{
  1675. TypeFilter: gjson.JSON,
  1676. Type: reflect.TypeOf(ToolStateCompleted{}),
  1677. DiscriminatorValue: "completed",
  1678. },
  1679. apijson.UnionVariant{
  1680. TypeFilter: gjson.JSON,
  1681. Type: reflect.TypeOf(ToolStateError{}),
  1682. DiscriminatorValue: "error",
  1683. },
  1684. )
  1685. }
  1686. type ToolPartStateStatus string
  1687. const (
  1688. ToolPartStateStatusPending ToolPartStateStatus = "pending"
  1689. ToolPartStateStatusRunning ToolPartStateStatus = "running"
  1690. ToolPartStateStatusCompleted ToolPartStateStatus = "completed"
  1691. ToolPartStateStatusError ToolPartStateStatus = "error"
  1692. )
  1693. func (r ToolPartStateStatus) IsKnown() bool {
  1694. switch r {
  1695. case ToolPartStateStatusPending, ToolPartStateStatusRunning, ToolPartStateStatusCompleted, ToolPartStateStatusError:
  1696. return true
  1697. }
  1698. return false
  1699. }
  1700. type ToolPartType string
  1701. const (
  1702. ToolPartTypeTool ToolPartType = "tool"
  1703. )
  1704. func (r ToolPartType) IsKnown() bool {
  1705. switch r {
  1706. case ToolPartTypeTool:
  1707. return true
  1708. }
  1709. return false
  1710. }
  1711. type ToolStateCompleted struct {
  1712. Input map[string]interface{} `json:"input,required"`
  1713. Metadata map[string]interface{} `json:"metadata,required"`
  1714. Output string `json:"output,required"`
  1715. Status ToolStateCompletedStatus `json:"status,required"`
  1716. Time ToolStateCompletedTime `json:"time,required"`
  1717. Title string `json:"title,required"`
  1718. JSON toolStateCompletedJSON `json:"-"`
  1719. }
  1720. // toolStateCompletedJSON contains the JSON metadata for the struct
  1721. // [ToolStateCompleted]
  1722. type toolStateCompletedJSON struct {
  1723. Input apijson.Field
  1724. Metadata apijson.Field
  1725. Output apijson.Field
  1726. Status apijson.Field
  1727. Time apijson.Field
  1728. Title apijson.Field
  1729. raw string
  1730. ExtraFields map[string]apijson.Field
  1731. }
  1732. func (r *ToolStateCompleted) UnmarshalJSON(data []byte) (err error) {
  1733. return apijson.UnmarshalRoot(data, r)
  1734. }
  1735. func (r toolStateCompletedJSON) RawJSON() string {
  1736. return r.raw
  1737. }
  1738. func (r ToolStateCompleted) implementsToolPartState() {}
  1739. type ToolStateCompletedStatus string
  1740. const (
  1741. ToolStateCompletedStatusCompleted ToolStateCompletedStatus = "completed"
  1742. )
  1743. func (r ToolStateCompletedStatus) IsKnown() bool {
  1744. switch r {
  1745. case ToolStateCompletedStatusCompleted:
  1746. return true
  1747. }
  1748. return false
  1749. }
  1750. type ToolStateCompletedTime struct {
  1751. End float64 `json:"end,required"`
  1752. Start float64 `json:"start,required"`
  1753. JSON toolStateCompletedTimeJSON `json:"-"`
  1754. }
  1755. // toolStateCompletedTimeJSON contains the JSON metadata for the struct
  1756. // [ToolStateCompletedTime]
  1757. type toolStateCompletedTimeJSON struct {
  1758. End apijson.Field
  1759. Start apijson.Field
  1760. raw string
  1761. ExtraFields map[string]apijson.Field
  1762. }
  1763. func (r *ToolStateCompletedTime) UnmarshalJSON(data []byte) (err error) {
  1764. return apijson.UnmarshalRoot(data, r)
  1765. }
  1766. func (r toolStateCompletedTimeJSON) RawJSON() string {
  1767. return r.raw
  1768. }
  1769. type ToolStateError struct {
  1770. Error string `json:"error,required"`
  1771. Input map[string]interface{} `json:"input,required"`
  1772. Status ToolStateErrorStatus `json:"status,required"`
  1773. Time ToolStateErrorTime `json:"time,required"`
  1774. Metadata map[string]interface{} `json:"metadata"`
  1775. JSON toolStateErrorJSON `json:"-"`
  1776. }
  1777. // toolStateErrorJSON contains the JSON metadata for the struct [ToolStateError]
  1778. type toolStateErrorJSON struct {
  1779. Error apijson.Field
  1780. Input apijson.Field
  1781. Status apijson.Field
  1782. Time apijson.Field
  1783. Metadata apijson.Field
  1784. raw string
  1785. ExtraFields map[string]apijson.Field
  1786. }
  1787. func (r *ToolStateError) UnmarshalJSON(data []byte) (err error) {
  1788. return apijson.UnmarshalRoot(data, r)
  1789. }
  1790. func (r toolStateErrorJSON) RawJSON() string {
  1791. return r.raw
  1792. }
  1793. func (r ToolStateError) implementsToolPartState() {}
  1794. type ToolStateErrorStatus string
  1795. const (
  1796. ToolStateErrorStatusError ToolStateErrorStatus = "error"
  1797. )
  1798. func (r ToolStateErrorStatus) IsKnown() bool {
  1799. switch r {
  1800. case ToolStateErrorStatusError:
  1801. return true
  1802. }
  1803. return false
  1804. }
  1805. type ToolStateErrorTime struct {
  1806. End float64 `json:"end,required"`
  1807. Start float64 `json:"start,required"`
  1808. JSON toolStateErrorTimeJSON `json:"-"`
  1809. }
  1810. // toolStateErrorTimeJSON contains the JSON metadata for the struct
  1811. // [ToolStateErrorTime]
  1812. type toolStateErrorTimeJSON struct {
  1813. End apijson.Field
  1814. Start apijson.Field
  1815. raw string
  1816. ExtraFields map[string]apijson.Field
  1817. }
  1818. func (r *ToolStateErrorTime) UnmarshalJSON(data []byte) (err error) {
  1819. return apijson.UnmarshalRoot(data, r)
  1820. }
  1821. func (r toolStateErrorTimeJSON) RawJSON() string {
  1822. return r.raw
  1823. }
  1824. type ToolStatePending struct {
  1825. Status ToolStatePendingStatus `json:"status,required"`
  1826. JSON toolStatePendingJSON `json:"-"`
  1827. }
  1828. // toolStatePendingJSON contains the JSON metadata for the struct
  1829. // [ToolStatePending]
  1830. type toolStatePendingJSON struct {
  1831. Status apijson.Field
  1832. raw string
  1833. ExtraFields map[string]apijson.Field
  1834. }
  1835. func (r *ToolStatePending) UnmarshalJSON(data []byte) (err error) {
  1836. return apijson.UnmarshalRoot(data, r)
  1837. }
  1838. func (r toolStatePendingJSON) RawJSON() string {
  1839. return r.raw
  1840. }
  1841. func (r ToolStatePending) implementsToolPartState() {}
  1842. type ToolStatePendingStatus string
  1843. const (
  1844. ToolStatePendingStatusPending ToolStatePendingStatus = "pending"
  1845. )
  1846. func (r ToolStatePendingStatus) IsKnown() bool {
  1847. switch r {
  1848. case ToolStatePendingStatusPending:
  1849. return true
  1850. }
  1851. return false
  1852. }
  1853. type ToolStateRunning struct {
  1854. Status ToolStateRunningStatus `json:"status,required"`
  1855. Time ToolStateRunningTime `json:"time,required"`
  1856. Input interface{} `json:"input"`
  1857. Metadata map[string]interface{} `json:"metadata"`
  1858. Title string `json:"title"`
  1859. JSON toolStateRunningJSON `json:"-"`
  1860. }
  1861. // toolStateRunningJSON contains the JSON metadata for the struct
  1862. // [ToolStateRunning]
  1863. type toolStateRunningJSON struct {
  1864. Status apijson.Field
  1865. Time apijson.Field
  1866. Input apijson.Field
  1867. Metadata apijson.Field
  1868. Title apijson.Field
  1869. raw string
  1870. ExtraFields map[string]apijson.Field
  1871. }
  1872. func (r *ToolStateRunning) UnmarshalJSON(data []byte) (err error) {
  1873. return apijson.UnmarshalRoot(data, r)
  1874. }
  1875. func (r toolStateRunningJSON) RawJSON() string {
  1876. return r.raw
  1877. }
  1878. func (r ToolStateRunning) implementsToolPartState() {}
  1879. type ToolStateRunningStatus string
  1880. const (
  1881. ToolStateRunningStatusRunning ToolStateRunningStatus = "running"
  1882. )
  1883. func (r ToolStateRunningStatus) IsKnown() bool {
  1884. switch r {
  1885. case ToolStateRunningStatusRunning:
  1886. return true
  1887. }
  1888. return false
  1889. }
  1890. type ToolStateRunningTime struct {
  1891. Start float64 `json:"start,required"`
  1892. JSON toolStateRunningTimeJSON `json:"-"`
  1893. }
  1894. // toolStateRunningTimeJSON contains the JSON metadata for the struct
  1895. // [ToolStateRunningTime]
  1896. type toolStateRunningTimeJSON struct {
  1897. Start apijson.Field
  1898. raw string
  1899. ExtraFields map[string]apijson.Field
  1900. }
  1901. func (r *ToolStateRunningTime) UnmarshalJSON(data []byte) (err error) {
  1902. return apijson.UnmarshalRoot(data, r)
  1903. }
  1904. func (r toolStateRunningTimeJSON) RawJSON() string {
  1905. return r.raw
  1906. }
  1907. type UserMessage struct {
  1908. ID string `json:"id,required"`
  1909. Role UserMessageRole `json:"role,required"`
  1910. SessionID string `json:"sessionID,required"`
  1911. Time UserMessageTime `json:"time,required"`
  1912. JSON userMessageJSON `json:"-"`
  1913. }
  1914. // userMessageJSON contains the JSON metadata for the struct [UserMessage]
  1915. type userMessageJSON struct {
  1916. ID apijson.Field
  1917. Role apijson.Field
  1918. SessionID apijson.Field
  1919. Time apijson.Field
  1920. raw string
  1921. ExtraFields map[string]apijson.Field
  1922. }
  1923. func (r *UserMessage) UnmarshalJSON(data []byte) (err error) {
  1924. return apijson.UnmarshalRoot(data, r)
  1925. }
  1926. func (r userMessageJSON) RawJSON() string {
  1927. return r.raw
  1928. }
  1929. func (r UserMessage) implementsMessage() {}
  1930. type UserMessageRole string
  1931. const (
  1932. UserMessageRoleUser UserMessageRole = "user"
  1933. )
  1934. func (r UserMessageRole) IsKnown() bool {
  1935. switch r {
  1936. case UserMessageRoleUser:
  1937. return true
  1938. }
  1939. return false
  1940. }
  1941. type UserMessageTime struct {
  1942. Created float64 `json:"created,required"`
  1943. JSON userMessageTimeJSON `json:"-"`
  1944. }
  1945. // userMessageTimeJSON contains the JSON metadata for the struct [UserMessageTime]
  1946. type userMessageTimeJSON struct {
  1947. Created apijson.Field
  1948. raw string
  1949. ExtraFields map[string]apijson.Field
  1950. }
  1951. func (r *UserMessageTime) UnmarshalJSON(data []byte) (err error) {
  1952. return apijson.UnmarshalRoot(data, r)
  1953. }
  1954. func (r userMessageTimeJSON) RawJSON() string {
  1955. return r.raw
  1956. }
  1957. type SessionCommandResponse struct {
  1958. Info AssistantMessage `json:"info,required"`
  1959. Parts []Part `json:"parts,required"`
  1960. JSON sessionCommandResponseJSON `json:"-"`
  1961. }
  1962. // sessionCommandResponseJSON contains the JSON metadata for the struct
  1963. // [SessionCommandResponse]
  1964. type sessionCommandResponseJSON struct {
  1965. Info apijson.Field
  1966. Parts apijson.Field
  1967. raw string
  1968. ExtraFields map[string]apijson.Field
  1969. }
  1970. func (r *SessionCommandResponse) UnmarshalJSON(data []byte) (err error) {
  1971. return apijson.UnmarshalRoot(data, r)
  1972. }
  1973. func (r sessionCommandResponseJSON) RawJSON() string {
  1974. return r.raw
  1975. }
  1976. type SessionMessageResponse struct {
  1977. Info Message `json:"info,required"`
  1978. Parts []Part `json:"parts,required"`
  1979. JSON sessionMessageResponseJSON `json:"-"`
  1980. }
  1981. // sessionMessageResponseJSON contains the JSON metadata for the struct
  1982. // [SessionMessageResponse]
  1983. type sessionMessageResponseJSON struct {
  1984. Info apijson.Field
  1985. Parts apijson.Field
  1986. raw string
  1987. ExtraFields map[string]apijson.Field
  1988. }
  1989. func (r *SessionMessageResponse) UnmarshalJSON(data []byte) (err error) {
  1990. return apijson.UnmarshalRoot(data, r)
  1991. }
  1992. func (r sessionMessageResponseJSON) RawJSON() string {
  1993. return r.raw
  1994. }
  1995. type SessionMessagesResponse struct {
  1996. Info Message `json:"info,required"`
  1997. Parts []Part `json:"parts,required"`
  1998. JSON sessionMessagesResponseJSON `json:"-"`
  1999. }
  2000. // sessionMessagesResponseJSON contains the JSON metadata for the struct
  2001. // [SessionMessagesResponse]
  2002. type sessionMessagesResponseJSON struct {
  2003. Info apijson.Field
  2004. Parts apijson.Field
  2005. raw string
  2006. ExtraFields map[string]apijson.Field
  2007. }
  2008. func (r *SessionMessagesResponse) UnmarshalJSON(data []byte) (err error) {
  2009. return apijson.UnmarshalRoot(data, r)
  2010. }
  2011. func (r sessionMessagesResponseJSON) RawJSON() string {
  2012. return r.raw
  2013. }
  2014. type SessionPromptResponse struct {
  2015. Info AssistantMessage `json:"info,required"`
  2016. Parts []Part `json:"parts,required"`
  2017. JSON sessionPromptResponseJSON `json:"-"`
  2018. }
  2019. // sessionPromptResponseJSON contains the JSON metadata for the struct
  2020. // [SessionPromptResponse]
  2021. type sessionPromptResponseJSON struct {
  2022. Info apijson.Field
  2023. Parts apijson.Field
  2024. raw string
  2025. ExtraFields map[string]apijson.Field
  2026. }
  2027. func (r *SessionPromptResponse) UnmarshalJSON(data []byte) (err error) {
  2028. return apijson.UnmarshalRoot(data, r)
  2029. }
  2030. func (r sessionPromptResponseJSON) RawJSON() string {
  2031. return r.raw
  2032. }
  2033. type SessionNewParams struct {
  2034. Directory param.Field[string] `query:"directory"`
  2035. ParentID param.Field[string] `json:"parentID"`
  2036. Title param.Field[string] `json:"title"`
  2037. }
  2038. func (r SessionNewParams) MarshalJSON() (data []byte, err error) {
  2039. return apijson.MarshalRoot(r)
  2040. }
  2041. // URLQuery serializes [SessionNewParams]'s query parameters as `url.Values`.
  2042. func (r SessionNewParams) URLQuery() (v url.Values) {
  2043. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2044. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2045. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2046. })
  2047. }
  2048. type SessionUpdateParams struct {
  2049. Directory param.Field[string] `query:"directory"`
  2050. Title param.Field[string] `json:"title"`
  2051. }
  2052. func (r SessionUpdateParams) MarshalJSON() (data []byte, err error) {
  2053. return apijson.MarshalRoot(r)
  2054. }
  2055. // URLQuery serializes [SessionUpdateParams]'s query parameters as `url.Values`.
  2056. func (r SessionUpdateParams) URLQuery() (v url.Values) {
  2057. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2058. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2059. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2060. })
  2061. }
  2062. type SessionListParams struct {
  2063. Directory param.Field[string] `query:"directory"`
  2064. }
  2065. // URLQuery serializes [SessionListParams]'s query parameters as `url.Values`.
  2066. func (r SessionListParams) URLQuery() (v url.Values) {
  2067. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2068. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2069. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2070. })
  2071. }
  2072. type SessionDeleteParams struct {
  2073. Directory param.Field[string] `query:"directory"`
  2074. }
  2075. // URLQuery serializes [SessionDeleteParams]'s query parameters as `url.Values`.
  2076. func (r SessionDeleteParams) URLQuery() (v url.Values) {
  2077. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2078. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2079. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2080. })
  2081. }
  2082. type SessionAbortParams struct {
  2083. Directory param.Field[string] `query:"directory"`
  2084. }
  2085. // URLQuery serializes [SessionAbortParams]'s query parameters as `url.Values`.
  2086. func (r SessionAbortParams) URLQuery() (v url.Values) {
  2087. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2088. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2089. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2090. })
  2091. }
  2092. type SessionChildrenParams struct {
  2093. Directory param.Field[string] `query:"directory"`
  2094. }
  2095. // URLQuery serializes [SessionChildrenParams]'s query parameters as `url.Values`.
  2096. func (r SessionChildrenParams) URLQuery() (v url.Values) {
  2097. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2098. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2099. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2100. })
  2101. }
  2102. type SessionCommandParams struct {
  2103. Arguments param.Field[string] `json:"arguments,required"`
  2104. Command param.Field[string] `json:"command,required"`
  2105. Directory param.Field[string] `query:"directory"`
  2106. Agent param.Field[string] `json:"agent"`
  2107. MessageID param.Field[string] `json:"messageID"`
  2108. Model param.Field[string] `json:"model"`
  2109. }
  2110. func (r SessionCommandParams) MarshalJSON() (data []byte, err error) {
  2111. return apijson.MarshalRoot(r)
  2112. }
  2113. // URLQuery serializes [SessionCommandParams]'s query parameters as `url.Values`.
  2114. func (r SessionCommandParams) URLQuery() (v url.Values) {
  2115. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2116. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2117. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2118. })
  2119. }
  2120. type SessionGetParams struct {
  2121. Directory param.Field[string] `query:"directory"`
  2122. }
  2123. // URLQuery serializes [SessionGetParams]'s query parameters as `url.Values`.
  2124. func (r SessionGetParams) URLQuery() (v url.Values) {
  2125. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2126. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2127. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2128. })
  2129. }
  2130. type SessionInitParams struct {
  2131. MessageID param.Field[string] `json:"messageID,required"`
  2132. ModelID param.Field[string] `json:"modelID,required"`
  2133. ProviderID param.Field[string] `json:"providerID,required"`
  2134. Directory param.Field[string] `query:"directory"`
  2135. }
  2136. func (r SessionInitParams) MarshalJSON() (data []byte, err error) {
  2137. return apijson.MarshalRoot(r)
  2138. }
  2139. // URLQuery serializes [SessionInitParams]'s query parameters as `url.Values`.
  2140. func (r SessionInitParams) URLQuery() (v url.Values) {
  2141. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2142. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2143. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2144. })
  2145. }
  2146. type SessionMessageParams struct {
  2147. Directory param.Field[string] `query:"directory"`
  2148. }
  2149. // URLQuery serializes [SessionMessageParams]'s query parameters as `url.Values`.
  2150. func (r SessionMessageParams) URLQuery() (v url.Values) {
  2151. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2152. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2153. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2154. })
  2155. }
  2156. type SessionMessagesParams struct {
  2157. Directory param.Field[string] `query:"directory"`
  2158. }
  2159. // URLQuery serializes [SessionMessagesParams]'s query parameters as `url.Values`.
  2160. func (r SessionMessagesParams) URLQuery() (v url.Values) {
  2161. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2162. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2163. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2164. })
  2165. }
  2166. type SessionPromptParams struct {
  2167. Parts param.Field[[]SessionPromptParamsPartUnion] `json:"parts,required"`
  2168. Directory param.Field[string] `query:"directory"`
  2169. Agent param.Field[string] `json:"agent"`
  2170. MessageID param.Field[string] `json:"messageID"`
  2171. Model param.Field[SessionPromptParamsModel] `json:"model"`
  2172. System param.Field[string] `json:"system"`
  2173. Tools param.Field[map[string]bool] `json:"tools"`
  2174. }
  2175. func (r SessionPromptParams) MarshalJSON() (data []byte, err error) {
  2176. return apijson.MarshalRoot(r)
  2177. }
  2178. // URLQuery serializes [SessionPromptParams]'s query parameters as `url.Values`.
  2179. func (r SessionPromptParams) URLQuery() (v url.Values) {
  2180. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2181. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2182. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2183. })
  2184. }
  2185. type SessionPromptParamsPart struct {
  2186. Type param.Field[SessionPromptParamsPartsType] `json:"type,required"`
  2187. ID param.Field[string] `json:"id"`
  2188. Filename param.Field[string] `json:"filename"`
  2189. Mime param.Field[string] `json:"mime"`
  2190. Name param.Field[string] `json:"name"`
  2191. Source param.Field[interface{}] `json:"source"`
  2192. Synthetic param.Field[bool] `json:"synthetic"`
  2193. Text param.Field[string] `json:"text"`
  2194. Time param.Field[interface{}] `json:"time"`
  2195. URL param.Field[string] `json:"url"`
  2196. }
  2197. func (r SessionPromptParamsPart) MarshalJSON() (data []byte, err error) {
  2198. return apijson.MarshalRoot(r)
  2199. }
  2200. func (r SessionPromptParamsPart) implementsSessionPromptParamsPartUnion() {}
  2201. // Satisfied by [TextPartInputParam], [FilePartInputParam], [AgentPartInputParam],
  2202. // [SessionPromptParamsPart].
  2203. type SessionPromptParamsPartUnion interface {
  2204. implementsSessionPromptParamsPartUnion()
  2205. }
  2206. type SessionPromptParamsPartsType string
  2207. const (
  2208. SessionPromptParamsPartsTypeText SessionPromptParamsPartsType = "text"
  2209. SessionPromptParamsPartsTypeFile SessionPromptParamsPartsType = "file"
  2210. SessionPromptParamsPartsTypeAgent SessionPromptParamsPartsType = "agent"
  2211. )
  2212. func (r SessionPromptParamsPartsType) IsKnown() bool {
  2213. switch r {
  2214. case SessionPromptParamsPartsTypeText, SessionPromptParamsPartsTypeFile, SessionPromptParamsPartsTypeAgent:
  2215. return true
  2216. }
  2217. return false
  2218. }
  2219. type SessionPromptParamsModel struct {
  2220. ModelID param.Field[string] `json:"modelID,required"`
  2221. ProviderID param.Field[string] `json:"providerID,required"`
  2222. }
  2223. func (r SessionPromptParamsModel) MarshalJSON() (data []byte, err error) {
  2224. return apijson.MarshalRoot(r)
  2225. }
  2226. type SessionRevertParams struct {
  2227. MessageID param.Field[string] `json:"messageID,required"`
  2228. Directory param.Field[string] `query:"directory"`
  2229. PartID param.Field[string] `json:"partID"`
  2230. }
  2231. func (r SessionRevertParams) MarshalJSON() (data []byte, err error) {
  2232. return apijson.MarshalRoot(r)
  2233. }
  2234. // URLQuery serializes [SessionRevertParams]'s query parameters as `url.Values`.
  2235. func (r SessionRevertParams) URLQuery() (v url.Values) {
  2236. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2237. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2238. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2239. })
  2240. }
  2241. type SessionShareParams struct {
  2242. Directory param.Field[string] `query:"directory"`
  2243. }
  2244. // URLQuery serializes [SessionShareParams]'s query parameters as `url.Values`.
  2245. func (r SessionShareParams) URLQuery() (v url.Values) {
  2246. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2247. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2248. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2249. })
  2250. }
  2251. type SessionShellParams struct {
  2252. Agent param.Field[string] `json:"agent,required"`
  2253. Command param.Field[string] `json:"command,required"`
  2254. Directory param.Field[string] `query:"directory"`
  2255. }
  2256. func (r SessionShellParams) MarshalJSON() (data []byte, err error) {
  2257. return apijson.MarshalRoot(r)
  2258. }
  2259. // URLQuery serializes [SessionShellParams]'s query parameters as `url.Values`.
  2260. func (r SessionShellParams) URLQuery() (v url.Values) {
  2261. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2262. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2263. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2264. })
  2265. }
  2266. type SessionSummarizeParams struct {
  2267. ModelID param.Field[string] `json:"modelID,required"`
  2268. ProviderID param.Field[string] `json:"providerID,required"`
  2269. Directory param.Field[string] `query:"directory"`
  2270. }
  2271. func (r SessionSummarizeParams) MarshalJSON() (data []byte, err error) {
  2272. return apijson.MarshalRoot(r)
  2273. }
  2274. // URLQuery serializes [SessionSummarizeParams]'s query parameters as `url.Values`.
  2275. func (r SessionSummarizeParams) URLQuery() (v url.Values) {
  2276. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2277. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2278. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2279. })
  2280. }
  2281. type SessionUnrevertParams struct {
  2282. Directory param.Field[string] `query:"directory"`
  2283. }
  2284. // URLQuery serializes [SessionUnrevertParams]'s query parameters as `url.Values`.
  2285. func (r SessionUnrevertParams) URLQuery() (v url.Values) {
  2286. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2287. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2288. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2289. })
  2290. }
  2291. type SessionUnshareParams struct {
  2292. Directory param.Field[string] `query:"directory"`
  2293. }
  2294. // URLQuery serializes [SessionUnshareParams]'s query parameters as `url.Values`.
  2295. func (r SessionUnshareParams) URLQuery() (v url.Values) {
  2296. return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
  2297. ArrayFormat: apiquery.ArrayQueryFormatComma,
  2298. NestedFormat: apiquery.NestedQueryFormatBrackets,
  2299. })
  2300. }