session.go 77 KB

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