session.go 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. package opencode
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "net/http"
  8. "reflect"
  9. "github.com/sst/opencode-sdk-go/internal/apijson"
  10. "github.com/sst/opencode-sdk-go/internal/param"
  11. "github.com/sst/opencode-sdk-go/internal/requestconfig"
  12. "github.com/sst/opencode-sdk-go/option"
  13. "github.com/sst/opencode-sdk-go/shared"
  14. "github.com/tidwall/gjson"
  15. )
  16. // SessionService contains methods and other services that help with interacting
  17. // with the opencode API.
  18. //
  19. // Note, unlike clients, this service does not read variables from the environment
  20. // automatically. You should not instantiate this service directly, and instead use
  21. // the [NewSessionService] method instead.
  22. type SessionService struct {
  23. Options []option.RequestOption
  24. }
  25. // NewSessionService generates a new service that applies the given options to each
  26. // request. These options are applied after the parent client's options (if there
  27. // is one), and before any request-specific options.
  28. func NewSessionService(opts ...option.RequestOption) (r *SessionService) {
  29. r = &SessionService{}
  30. r.Options = opts
  31. return
  32. }
  33. // Create a new session
  34. func (r *SessionService) New(ctx context.Context, opts ...option.RequestOption) (res *Session, err error) {
  35. opts = append(r.Options[:], opts...)
  36. path := "session"
  37. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  38. return
  39. }
  40. // List all sessions
  41. func (r *SessionService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Session, err error) {
  42. opts = append(r.Options[:], opts...)
  43. path := "session"
  44. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  45. return
  46. }
  47. // Delete a session and all its data
  48. func (r *SessionService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (res *bool, err error) {
  49. opts = append(r.Options[:], opts...)
  50. if id == "" {
  51. err = errors.New("missing required id parameter")
  52. return
  53. }
  54. path := fmt.Sprintf("session/%s", id)
  55. err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
  56. return
  57. }
  58. // Abort a session
  59. func (r *SessionService) Abort(ctx context.Context, id string, opts ...option.RequestOption) (res *bool, err error) {
  60. opts = append(r.Options[:], opts...)
  61. if id == "" {
  62. err = errors.New("missing required id parameter")
  63. return
  64. }
  65. path := fmt.Sprintf("session/%s/abort", id)
  66. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  67. return
  68. }
  69. // Create and send a new message to a session
  70. func (r *SessionService) Chat(ctx context.Context, id string, body SessionChatParams, opts ...option.RequestOption) (res *AssistantMessage, err error) {
  71. opts = append(r.Options[:], opts...)
  72. if id == "" {
  73. err = errors.New("missing required id parameter")
  74. return
  75. }
  76. path := fmt.Sprintf("session/%s/message", id)
  77. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  78. return
  79. }
  80. // Analyze the app and create an AGENTS.md file
  81. func (r *SessionService) Init(ctx context.Context, id string, body SessionInitParams, opts ...option.RequestOption) (res *bool, err error) {
  82. opts = append(r.Options[:], opts...)
  83. if id == "" {
  84. err = errors.New("missing required id parameter")
  85. return
  86. }
  87. path := fmt.Sprintf("session/%s/init", id)
  88. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  89. return
  90. }
  91. // List messages for a session
  92. func (r *SessionService) Messages(ctx context.Context, id string, opts ...option.RequestOption) (res *[]SessionMessagesResponse, err error) {
  93. opts = append(r.Options[:], opts...)
  94. if id == "" {
  95. err = errors.New("missing required id parameter")
  96. return
  97. }
  98. path := fmt.Sprintf("session/%s/message", id)
  99. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  100. return
  101. }
  102. // Revert a message
  103. func (r *SessionService) Revert(ctx context.Context, id string, body SessionRevertParams, opts ...option.RequestOption) (res *Session, err error) {
  104. opts = append(r.Options[:], opts...)
  105. if id == "" {
  106. err = errors.New("missing required id parameter")
  107. return
  108. }
  109. path := fmt.Sprintf("session/%s/revert", id)
  110. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  111. return
  112. }
  113. // Share a session
  114. func (r *SessionService) Share(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  115. opts = append(r.Options[:], opts...)
  116. if id == "" {
  117. err = errors.New("missing required id parameter")
  118. return
  119. }
  120. path := fmt.Sprintf("session/%s/share", id)
  121. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  122. return
  123. }
  124. // Summarize the session
  125. func (r *SessionService) Summarize(ctx context.Context, id string, body SessionSummarizeParams, opts ...option.RequestOption) (res *bool, err error) {
  126. opts = append(r.Options[:], opts...)
  127. if id == "" {
  128. err = errors.New("missing required id parameter")
  129. return
  130. }
  131. path := fmt.Sprintf("session/%s/summarize", id)
  132. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  133. return
  134. }
  135. // Restore all reverted messages
  136. func (r *SessionService) Unrevert(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  137. opts = append(r.Options[:], opts...)
  138. if id == "" {
  139. err = errors.New("missing required id parameter")
  140. return
  141. }
  142. path := fmt.Sprintf("session/%s/unrevert", id)
  143. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  144. return
  145. }
  146. // Unshare the session
  147. func (r *SessionService) Unshare(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
  148. opts = append(r.Options[:], opts...)
  149. if id == "" {
  150. err = errors.New("missing required id parameter")
  151. return
  152. }
  153. path := fmt.Sprintf("session/%s/share", id)
  154. err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
  155. return
  156. }
  157. type AssistantMessage struct {
  158. ID string `json:"id,required"`
  159. Cost float64 `json:"cost,required"`
  160. Mode string `json:"mode,required"`
  161. ModelID string `json:"modelID,required"`
  162. Path AssistantMessagePath `json:"path,required"`
  163. ProviderID string `json:"providerID,required"`
  164. Role AssistantMessageRole `json:"role,required"`
  165. SessionID string `json:"sessionID,required"`
  166. System []string `json:"system,required"`
  167. Time AssistantMessageTime `json:"time,required"`
  168. Tokens AssistantMessageTokens `json:"tokens,required"`
  169. Error AssistantMessageError `json:"error"`
  170. Summary bool `json:"summary"`
  171. JSON assistantMessageJSON `json:"-"`
  172. }
  173. // assistantMessageJSON contains the JSON metadata for the struct
  174. // [AssistantMessage]
  175. type assistantMessageJSON struct {
  176. ID apijson.Field
  177. Cost apijson.Field
  178. Mode apijson.Field
  179. ModelID apijson.Field
  180. Path apijson.Field
  181. ProviderID apijson.Field
  182. Role apijson.Field
  183. SessionID apijson.Field
  184. System apijson.Field
  185. Time apijson.Field
  186. Tokens apijson.Field
  187. Error apijson.Field
  188. Summary apijson.Field
  189. raw string
  190. ExtraFields map[string]apijson.Field
  191. }
  192. func (r *AssistantMessage) UnmarshalJSON(data []byte) (err error) {
  193. return apijson.UnmarshalRoot(data, r)
  194. }
  195. func (r assistantMessageJSON) RawJSON() string {
  196. return r.raw
  197. }
  198. func (r AssistantMessage) implementsMessage() {}
  199. type AssistantMessagePath struct {
  200. Cwd string `json:"cwd,required"`
  201. Root string `json:"root,required"`
  202. JSON assistantMessagePathJSON `json:"-"`
  203. }
  204. // assistantMessagePathJSON contains the JSON metadata for the struct
  205. // [AssistantMessagePath]
  206. type assistantMessagePathJSON struct {
  207. Cwd apijson.Field
  208. Root apijson.Field
  209. raw string
  210. ExtraFields map[string]apijson.Field
  211. }
  212. func (r *AssistantMessagePath) UnmarshalJSON(data []byte) (err error) {
  213. return apijson.UnmarshalRoot(data, r)
  214. }
  215. func (r assistantMessagePathJSON) RawJSON() string {
  216. return r.raw
  217. }
  218. type AssistantMessageRole string
  219. const (
  220. AssistantMessageRoleAssistant AssistantMessageRole = "assistant"
  221. )
  222. func (r AssistantMessageRole) IsKnown() bool {
  223. switch r {
  224. case AssistantMessageRoleAssistant:
  225. return true
  226. }
  227. return false
  228. }
  229. type AssistantMessageTime struct {
  230. Created float64 `json:"created,required"`
  231. Completed float64 `json:"completed"`
  232. JSON assistantMessageTimeJSON `json:"-"`
  233. }
  234. // assistantMessageTimeJSON contains the JSON metadata for the struct
  235. // [AssistantMessageTime]
  236. type assistantMessageTimeJSON struct {
  237. Created apijson.Field
  238. Completed apijson.Field
  239. raw string
  240. ExtraFields map[string]apijson.Field
  241. }
  242. func (r *AssistantMessageTime) UnmarshalJSON(data []byte) (err error) {
  243. return apijson.UnmarshalRoot(data, r)
  244. }
  245. func (r assistantMessageTimeJSON) RawJSON() string {
  246. return r.raw
  247. }
  248. type AssistantMessageTokens struct {
  249. Cache AssistantMessageTokensCache `json:"cache,required"`
  250. Input float64 `json:"input,required"`
  251. Output float64 `json:"output,required"`
  252. Reasoning float64 `json:"reasoning,required"`
  253. JSON assistantMessageTokensJSON `json:"-"`
  254. }
  255. // assistantMessageTokensJSON contains the JSON metadata for the struct
  256. // [AssistantMessageTokens]
  257. type assistantMessageTokensJSON struct {
  258. Cache apijson.Field
  259. Input apijson.Field
  260. Output apijson.Field
  261. Reasoning apijson.Field
  262. raw string
  263. ExtraFields map[string]apijson.Field
  264. }
  265. func (r *AssistantMessageTokens) UnmarshalJSON(data []byte) (err error) {
  266. return apijson.UnmarshalRoot(data, r)
  267. }
  268. func (r assistantMessageTokensJSON) RawJSON() string {
  269. return r.raw
  270. }
  271. type AssistantMessageTokensCache struct {
  272. Read float64 `json:"read,required"`
  273. Write float64 `json:"write,required"`
  274. JSON assistantMessageTokensCacheJSON `json:"-"`
  275. }
  276. // assistantMessageTokensCacheJSON contains the JSON metadata for the struct
  277. // [AssistantMessageTokensCache]
  278. type assistantMessageTokensCacheJSON struct {
  279. Read apijson.Field
  280. Write apijson.Field
  281. raw string
  282. ExtraFields map[string]apijson.Field
  283. }
  284. func (r *AssistantMessageTokensCache) UnmarshalJSON(data []byte) (err error) {
  285. return apijson.UnmarshalRoot(data, r)
  286. }
  287. func (r assistantMessageTokensCacheJSON) RawJSON() string {
  288. return r.raw
  289. }
  290. type AssistantMessageError struct {
  291. // This field can have the runtime type of [shared.ProviderAuthErrorData],
  292. // [shared.UnknownErrorData], [interface{}].
  293. Data interface{} `json:"data,required"`
  294. Name AssistantMessageErrorName `json:"name,required"`
  295. JSON assistantMessageErrorJSON `json:"-"`
  296. union AssistantMessageErrorUnion
  297. }
  298. // assistantMessageErrorJSON contains the JSON metadata for the struct
  299. // [AssistantMessageError]
  300. type assistantMessageErrorJSON struct {
  301. Data apijson.Field
  302. Name apijson.Field
  303. raw string
  304. ExtraFields map[string]apijson.Field
  305. }
  306. func (r assistantMessageErrorJSON) RawJSON() string {
  307. return r.raw
  308. }
  309. func (r *AssistantMessageError) UnmarshalJSON(data []byte) (err error) {
  310. *r = AssistantMessageError{}
  311. err = apijson.UnmarshalRoot(data, &r.union)
  312. if err != nil {
  313. return err
  314. }
  315. return apijson.Port(r.union, &r)
  316. }
  317. // AsUnion returns a [AssistantMessageErrorUnion] interface which you can cast to
  318. // the specific types for more type safety.
  319. //
  320. // Possible runtime types of the union are [shared.ProviderAuthError],
  321. // [shared.UnknownError], [AssistantMessageErrorMessageOutputLengthError],
  322. // [shared.MessageAbortedError].
  323. func (r AssistantMessageError) AsUnion() AssistantMessageErrorUnion {
  324. return r.union
  325. }
  326. // Union satisfied by [shared.ProviderAuthError], [shared.UnknownError],
  327. // [AssistantMessageErrorMessageOutputLengthError] or [shared.MessageAbortedError].
  328. type AssistantMessageErrorUnion interface {
  329. ImplementsAssistantMessageError()
  330. }
  331. func init() {
  332. apijson.RegisterUnion(
  333. reflect.TypeOf((*AssistantMessageErrorUnion)(nil)).Elem(),
  334. "name",
  335. apijson.UnionVariant{
  336. TypeFilter: gjson.JSON,
  337. Type: reflect.TypeOf(shared.ProviderAuthError{}),
  338. DiscriminatorValue: "ProviderAuthError",
  339. },
  340. apijson.UnionVariant{
  341. TypeFilter: gjson.JSON,
  342. Type: reflect.TypeOf(shared.UnknownError{}),
  343. DiscriminatorValue: "UnknownError",
  344. },
  345. apijson.UnionVariant{
  346. TypeFilter: gjson.JSON,
  347. Type: reflect.TypeOf(AssistantMessageErrorMessageOutputLengthError{}),
  348. DiscriminatorValue: "MessageOutputLengthError",
  349. },
  350. apijson.UnionVariant{
  351. TypeFilter: gjson.JSON,
  352. Type: reflect.TypeOf(shared.MessageAbortedError{}),
  353. DiscriminatorValue: "MessageAbortedError",
  354. },
  355. )
  356. }
  357. type AssistantMessageErrorMessageOutputLengthError struct {
  358. Data interface{} `json:"data,required"`
  359. Name AssistantMessageErrorMessageOutputLengthErrorName `json:"name,required"`
  360. JSON assistantMessageErrorMessageOutputLengthErrorJSON `json:"-"`
  361. }
  362. // assistantMessageErrorMessageOutputLengthErrorJSON contains the JSON metadata for
  363. // the struct [AssistantMessageErrorMessageOutputLengthError]
  364. type assistantMessageErrorMessageOutputLengthErrorJSON struct {
  365. Data apijson.Field
  366. Name apijson.Field
  367. raw string
  368. ExtraFields map[string]apijson.Field
  369. }
  370. func (r *AssistantMessageErrorMessageOutputLengthError) UnmarshalJSON(data []byte) (err error) {
  371. return apijson.UnmarshalRoot(data, r)
  372. }
  373. func (r assistantMessageErrorMessageOutputLengthErrorJSON) RawJSON() string {
  374. return r.raw
  375. }
  376. func (r AssistantMessageErrorMessageOutputLengthError) ImplementsAssistantMessageError() {}
  377. type AssistantMessageErrorMessageOutputLengthErrorName string
  378. const (
  379. AssistantMessageErrorMessageOutputLengthErrorNameMessageOutputLengthError AssistantMessageErrorMessageOutputLengthErrorName = "MessageOutputLengthError"
  380. )
  381. func (r AssistantMessageErrorMessageOutputLengthErrorName) IsKnown() bool {
  382. switch r {
  383. case AssistantMessageErrorMessageOutputLengthErrorNameMessageOutputLengthError:
  384. return true
  385. }
  386. return false
  387. }
  388. type AssistantMessageErrorName string
  389. const (
  390. AssistantMessageErrorNameProviderAuthError AssistantMessageErrorName = "ProviderAuthError"
  391. AssistantMessageErrorNameUnknownError AssistantMessageErrorName = "UnknownError"
  392. AssistantMessageErrorNameMessageOutputLengthError AssistantMessageErrorName = "MessageOutputLengthError"
  393. AssistantMessageErrorNameMessageAbortedError AssistantMessageErrorName = "MessageAbortedError"
  394. )
  395. func (r AssistantMessageErrorName) IsKnown() bool {
  396. switch r {
  397. case AssistantMessageErrorNameProviderAuthError, AssistantMessageErrorNameUnknownError, AssistantMessageErrorNameMessageOutputLengthError, AssistantMessageErrorNameMessageAbortedError:
  398. return true
  399. }
  400. return false
  401. }
  402. type FilePart struct {
  403. ID string `json:"id,required"`
  404. MessageID string `json:"messageID,required"`
  405. Mime string `json:"mime,required"`
  406. SessionID string `json:"sessionID,required"`
  407. Type FilePartType `json:"type,required"`
  408. URL string `json:"url,required"`
  409. Filename string `json:"filename"`
  410. Source FilePartSource `json:"source"`
  411. JSON filePartJSON `json:"-"`
  412. }
  413. // filePartJSON contains the JSON metadata for the struct [FilePart]
  414. type filePartJSON struct {
  415. ID apijson.Field
  416. MessageID apijson.Field
  417. Mime apijson.Field
  418. SessionID apijson.Field
  419. Type apijson.Field
  420. URL apijson.Field
  421. Filename apijson.Field
  422. Source apijson.Field
  423. raw string
  424. ExtraFields map[string]apijson.Field
  425. }
  426. func (r *FilePart) UnmarshalJSON(data []byte) (err error) {
  427. return apijson.UnmarshalRoot(data, r)
  428. }
  429. func (r filePartJSON) RawJSON() string {
  430. return r.raw
  431. }
  432. func (r FilePart) implementsPart() {}
  433. type FilePartType string
  434. const (
  435. FilePartTypeFile FilePartType = "file"
  436. )
  437. func (r FilePartType) IsKnown() bool {
  438. switch r {
  439. case FilePartTypeFile:
  440. return true
  441. }
  442. return false
  443. }
  444. type FilePartInputParam struct {
  445. Mime param.Field[string] `json:"mime,required"`
  446. Type param.Field[FilePartInputType] `json:"type,required"`
  447. URL param.Field[string] `json:"url,required"`
  448. ID param.Field[string] `json:"id"`
  449. Filename param.Field[string] `json:"filename"`
  450. Source param.Field[FilePartSourceUnionParam] `json:"source"`
  451. }
  452. func (r FilePartInputParam) MarshalJSON() (data []byte, err error) {
  453. return apijson.MarshalRoot(r)
  454. }
  455. func (r FilePartInputParam) implementsSessionChatParamsPartUnion() {}
  456. type FilePartInputType string
  457. const (
  458. FilePartInputTypeFile FilePartInputType = "file"
  459. )
  460. func (r FilePartInputType) IsKnown() bool {
  461. switch r {
  462. case FilePartInputTypeFile:
  463. return true
  464. }
  465. return false
  466. }
  467. type FilePartSource struct {
  468. Path string `json:"path,required"`
  469. Text FilePartSourceText `json:"text,required"`
  470. Type FilePartSourceType `json:"type,required"`
  471. Kind int64 `json:"kind"`
  472. Name string `json:"name"`
  473. // This field can have the runtime type of [SymbolSourceRange].
  474. Range interface{} `json:"range"`
  475. JSON filePartSourceJSON `json:"-"`
  476. union FilePartSourceUnion
  477. }
  478. // filePartSourceJSON contains the JSON metadata for the struct [FilePartSource]
  479. type filePartSourceJSON struct {
  480. Path apijson.Field
  481. Text apijson.Field
  482. Type apijson.Field
  483. Kind apijson.Field
  484. Name apijson.Field
  485. Range apijson.Field
  486. raw string
  487. ExtraFields map[string]apijson.Field
  488. }
  489. func (r filePartSourceJSON) RawJSON() string {
  490. return r.raw
  491. }
  492. func (r *FilePartSource) UnmarshalJSON(data []byte) (err error) {
  493. *r = FilePartSource{}
  494. err = apijson.UnmarshalRoot(data, &r.union)
  495. if err != nil {
  496. return err
  497. }
  498. return apijson.Port(r.union, &r)
  499. }
  500. // AsUnion returns a [FilePartSourceUnion] interface which you can cast to the
  501. // specific types for more type safety.
  502. //
  503. // Possible runtime types of the union are [FileSource], [SymbolSource].
  504. func (r FilePartSource) AsUnion() FilePartSourceUnion {
  505. return r.union
  506. }
  507. // Union satisfied by [FileSource] or [SymbolSource].
  508. type FilePartSourceUnion interface {
  509. implementsFilePartSource()
  510. }
  511. func init() {
  512. apijson.RegisterUnion(
  513. reflect.TypeOf((*FilePartSourceUnion)(nil)).Elem(),
  514. "type",
  515. apijson.UnionVariant{
  516. TypeFilter: gjson.JSON,
  517. Type: reflect.TypeOf(FileSource{}),
  518. DiscriminatorValue: "file",
  519. },
  520. apijson.UnionVariant{
  521. TypeFilter: gjson.JSON,
  522. Type: reflect.TypeOf(SymbolSource{}),
  523. DiscriminatorValue: "symbol",
  524. },
  525. )
  526. }
  527. type FilePartSourceType string
  528. const (
  529. FilePartSourceTypeFile FilePartSourceType = "file"
  530. FilePartSourceTypeSymbol FilePartSourceType = "symbol"
  531. )
  532. func (r FilePartSourceType) IsKnown() bool {
  533. switch r {
  534. case FilePartSourceTypeFile, FilePartSourceTypeSymbol:
  535. return true
  536. }
  537. return false
  538. }
  539. type FilePartSourceParam struct {
  540. Path param.Field[string] `json:"path,required"`
  541. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  542. Type param.Field[FilePartSourceType] `json:"type,required"`
  543. Kind param.Field[int64] `json:"kind"`
  544. Name param.Field[string] `json:"name"`
  545. Range param.Field[interface{}] `json:"range"`
  546. }
  547. func (r FilePartSourceParam) MarshalJSON() (data []byte, err error) {
  548. return apijson.MarshalRoot(r)
  549. }
  550. func (r FilePartSourceParam) implementsFilePartSourceUnionParam() {}
  551. // Satisfied by [FileSourceParam], [SymbolSourceParam], [FilePartSourceParam].
  552. type FilePartSourceUnionParam interface {
  553. implementsFilePartSourceUnionParam()
  554. }
  555. type FilePartSourceText struct {
  556. End int64 `json:"end,required"`
  557. Start int64 `json:"start,required"`
  558. Value string `json:"value,required"`
  559. JSON filePartSourceTextJSON `json:"-"`
  560. }
  561. // filePartSourceTextJSON contains the JSON metadata for the struct
  562. // [FilePartSourceText]
  563. type filePartSourceTextJSON struct {
  564. End apijson.Field
  565. Start apijson.Field
  566. Value apijson.Field
  567. raw string
  568. ExtraFields map[string]apijson.Field
  569. }
  570. func (r *FilePartSourceText) UnmarshalJSON(data []byte) (err error) {
  571. return apijson.UnmarshalRoot(data, r)
  572. }
  573. func (r filePartSourceTextJSON) RawJSON() string {
  574. return r.raw
  575. }
  576. type FilePartSourceTextParam struct {
  577. End param.Field[int64] `json:"end,required"`
  578. Start param.Field[int64] `json:"start,required"`
  579. Value param.Field[string] `json:"value,required"`
  580. }
  581. func (r FilePartSourceTextParam) MarshalJSON() (data []byte, err error) {
  582. return apijson.MarshalRoot(r)
  583. }
  584. type FileSource struct {
  585. Path string `json:"path,required"`
  586. Text FilePartSourceText `json:"text,required"`
  587. Type FileSourceType `json:"type,required"`
  588. JSON fileSourceJSON `json:"-"`
  589. }
  590. // fileSourceJSON contains the JSON metadata for the struct [FileSource]
  591. type fileSourceJSON struct {
  592. Path apijson.Field
  593. Text apijson.Field
  594. Type apijson.Field
  595. raw string
  596. ExtraFields map[string]apijson.Field
  597. }
  598. func (r *FileSource) UnmarshalJSON(data []byte) (err error) {
  599. return apijson.UnmarshalRoot(data, r)
  600. }
  601. func (r fileSourceJSON) RawJSON() string {
  602. return r.raw
  603. }
  604. func (r FileSource) implementsFilePartSource() {}
  605. type FileSourceType string
  606. const (
  607. FileSourceTypeFile FileSourceType = "file"
  608. )
  609. func (r FileSourceType) IsKnown() bool {
  610. switch r {
  611. case FileSourceTypeFile:
  612. return true
  613. }
  614. return false
  615. }
  616. type FileSourceParam struct {
  617. Path param.Field[string] `json:"path,required"`
  618. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  619. Type param.Field[FileSourceType] `json:"type,required"`
  620. }
  621. func (r FileSourceParam) MarshalJSON() (data []byte, err error) {
  622. return apijson.MarshalRoot(r)
  623. }
  624. func (r FileSourceParam) implementsFilePartSourceUnionParam() {}
  625. type Message struct {
  626. ID string `json:"id,required"`
  627. Role MessageRole `json:"role,required"`
  628. SessionID string `json:"sessionID,required"`
  629. // This field can have the runtime type of [UserMessageTime],
  630. // [AssistantMessageTime].
  631. Time interface{} `json:"time,required"`
  632. Cost float64 `json:"cost"`
  633. // This field can have the runtime type of [AssistantMessageError].
  634. Error interface{} `json:"error"`
  635. Mode string `json:"mode"`
  636. ModelID string `json:"modelID"`
  637. // This field can have the runtime type of [AssistantMessagePath].
  638. Path interface{} `json:"path"`
  639. ProviderID string `json:"providerID"`
  640. Summary bool `json:"summary"`
  641. // This field can have the runtime type of [[]string].
  642. System interface{} `json:"system"`
  643. // This field can have the runtime type of [AssistantMessageTokens].
  644. Tokens interface{} `json:"tokens"`
  645. JSON messageJSON `json:"-"`
  646. union MessageUnion
  647. }
  648. // messageJSON contains the JSON metadata for the struct [Message]
  649. type messageJSON struct {
  650. ID apijson.Field
  651. Role apijson.Field
  652. SessionID apijson.Field
  653. Time apijson.Field
  654. Cost apijson.Field
  655. Error apijson.Field
  656. Mode apijson.Field
  657. ModelID apijson.Field
  658. Path apijson.Field
  659. ProviderID apijson.Field
  660. Summary apijson.Field
  661. System apijson.Field
  662. Tokens apijson.Field
  663. raw string
  664. ExtraFields map[string]apijson.Field
  665. }
  666. func (r messageJSON) RawJSON() string {
  667. return r.raw
  668. }
  669. func (r *Message) UnmarshalJSON(data []byte) (err error) {
  670. *r = Message{}
  671. err = apijson.UnmarshalRoot(data, &r.union)
  672. if err != nil {
  673. return err
  674. }
  675. return apijson.Port(r.union, &r)
  676. }
  677. // AsUnion returns a [MessageUnion] interface which you can cast to the specific
  678. // types for more type safety.
  679. //
  680. // Possible runtime types of the union are [UserMessage], [AssistantMessage].
  681. func (r Message) AsUnion() MessageUnion {
  682. return r.union
  683. }
  684. // Union satisfied by [UserMessage] or [AssistantMessage].
  685. type MessageUnion interface {
  686. implementsMessage()
  687. }
  688. func init() {
  689. apijson.RegisterUnion(
  690. reflect.TypeOf((*MessageUnion)(nil)).Elem(),
  691. "role",
  692. apijson.UnionVariant{
  693. TypeFilter: gjson.JSON,
  694. Type: reflect.TypeOf(UserMessage{}),
  695. DiscriminatorValue: "user",
  696. },
  697. apijson.UnionVariant{
  698. TypeFilter: gjson.JSON,
  699. Type: reflect.TypeOf(AssistantMessage{}),
  700. DiscriminatorValue: "assistant",
  701. },
  702. )
  703. }
  704. type MessageRole string
  705. const (
  706. MessageRoleUser MessageRole = "user"
  707. MessageRoleAssistant MessageRole = "assistant"
  708. )
  709. func (r MessageRole) IsKnown() bool {
  710. switch r {
  711. case MessageRoleUser, MessageRoleAssistant:
  712. return true
  713. }
  714. return false
  715. }
  716. type Part struct {
  717. ID string `json:"id,required"`
  718. MessageID string `json:"messageID,required"`
  719. SessionID string `json:"sessionID,required"`
  720. Type PartType `json:"type,required"`
  721. CallID string `json:"callID"`
  722. Cost float64 `json:"cost"`
  723. Filename string `json:"filename"`
  724. // This field can have the runtime type of [[]string].
  725. Files interface{} `json:"files"`
  726. Hash string `json:"hash"`
  727. Mime string `json:"mime"`
  728. Snapshot string `json:"snapshot"`
  729. Source FilePartSource `json:"source"`
  730. // This field can have the runtime type of [ToolPartState].
  731. State interface{} `json:"state"`
  732. Synthetic bool `json:"synthetic"`
  733. Text string `json:"text"`
  734. // This field can have the runtime type of [TextPartTime].
  735. Time interface{} `json:"time"`
  736. // This field can have the runtime type of [StepFinishPartTokens].
  737. Tokens interface{} `json:"tokens"`
  738. Tool string `json:"tool"`
  739. URL string `json:"url"`
  740. JSON partJSON `json:"-"`
  741. union PartUnion
  742. }
  743. // partJSON contains the JSON metadata for the struct [Part]
  744. type partJSON struct {
  745. ID apijson.Field
  746. MessageID apijson.Field
  747. SessionID apijson.Field
  748. Type apijson.Field
  749. CallID apijson.Field
  750. Cost apijson.Field
  751. Filename apijson.Field
  752. Files apijson.Field
  753. Hash apijson.Field
  754. Mime apijson.Field
  755. Snapshot apijson.Field
  756. Source apijson.Field
  757. State apijson.Field
  758. Synthetic apijson.Field
  759. Text apijson.Field
  760. Time apijson.Field
  761. Tokens apijson.Field
  762. Tool apijson.Field
  763. URL apijson.Field
  764. raw string
  765. ExtraFields map[string]apijson.Field
  766. }
  767. func (r partJSON) RawJSON() string {
  768. return r.raw
  769. }
  770. func (r *Part) UnmarshalJSON(data []byte) (err error) {
  771. *r = Part{}
  772. err = apijson.UnmarshalRoot(data, &r.union)
  773. if err != nil {
  774. return err
  775. }
  776. return apijson.Port(r.union, &r)
  777. }
  778. // AsUnion returns a [PartUnion] interface which you can cast to the specific types
  779. // for more type safety.
  780. //
  781. // Possible runtime types of the union are [TextPart], [FilePart], [ToolPart],
  782. // [StepStartPart], [StepFinishPart], [SnapshotPart], [PartPatchPart].
  783. func (r Part) AsUnion() PartUnion {
  784. return r.union
  785. }
  786. // Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart],
  787. // [StepFinishPart], [SnapshotPart] or [PartPatchPart].
  788. type PartUnion interface {
  789. implementsPart()
  790. }
  791. func init() {
  792. apijson.RegisterUnion(
  793. reflect.TypeOf((*PartUnion)(nil)).Elem(),
  794. "type",
  795. apijson.UnionVariant{
  796. TypeFilter: gjson.JSON,
  797. Type: reflect.TypeOf(TextPart{}),
  798. DiscriminatorValue: "text",
  799. },
  800. apijson.UnionVariant{
  801. TypeFilter: gjson.JSON,
  802. Type: reflect.TypeOf(FilePart{}),
  803. DiscriminatorValue: "file",
  804. },
  805. apijson.UnionVariant{
  806. TypeFilter: gjson.JSON,
  807. Type: reflect.TypeOf(ToolPart{}),
  808. DiscriminatorValue: "tool",
  809. },
  810. apijson.UnionVariant{
  811. TypeFilter: gjson.JSON,
  812. Type: reflect.TypeOf(StepStartPart{}),
  813. DiscriminatorValue: "step-start",
  814. },
  815. apijson.UnionVariant{
  816. TypeFilter: gjson.JSON,
  817. Type: reflect.TypeOf(StepFinishPart{}),
  818. DiscriminatorValue: "step-finish",
  819. },
  820. apijson.UnionVariant{
  821. TypeFilter: gjson.JSON,
  822. Type: reflect.TypeOf(SnapshotPart{}),
  823. DiscriminatorValue: "snapshot",
  824. },
  825. apijson.UnionVariant{
  826. TypeFilter: gjson.JSON,
  827. Type: reflect.TypeOf(PartPatchPart{}),
  828. DiscriminatorValue: "patch",
  829. },
  830. )
  831. }
  832. type PartPatchPart struct {
  833. ID string `json:"id,required"`
  834. Files []string `json:"files,required"`
  835. Hash string `json:"hash,required"`
  836. MessageID string `json:"messageID,required"`
  837. SessionID string `json:"sessionID,required"`
  838. Type PartPatchPartType `json:"type,required"`
  839. JSON partPatchPartJSON `json:"-"`
  840. }
  841. // partPatchPartJSON contains the JSON metadata for the struct [PartPatchPart]
  842. type partPatchPartJSON struct {
  843. ID apijson.Field
  844. Files apijson.Field
  845. Hash apijson.Field
  846. MessageID apijson.Field
  847. SessionID apijson.Field
  848. Type apijson.Field
  849. raw string
  850. ExtraFields map[string]apijson.Field
  851. }
  852. func (r *PartPatchPart) UnmarshalJSON(data []byte) (err error) {
  853. return apijson.UnmarshalRoot(data, r)
  854. }
  855. func (r partPatchPartJSON) RawJSON() string {
  856. return r.raw
  857. }
  858. func (r PartPatchPart) implementsPart() {}
  859. type PartPatchPartType string
  860. const (
  861. PartPatchPartTypePatch PartPatchPartType = "patch"
  862. )
  863. func (r PartPatchPartType) IsKnown() bool {
  864. switch r {
  865. case PartPatchPartTypePatch:
  866. return true
  867. }
  868. return false
  869. }
  870. type PartType string
  871. const (
  872. PartTypeText PartType = "text"
  873. PartTypeFile PartType = "file"
  874. PartTypeTool PartType = "tool"
  875. PartTypeStepStart PartType = "step-start"
  876. PartTypeStepFinish PartType = "step-finish"
  877. PartTypeSnapshot PartType = "snapshot"
  878. PartTypePatch PartType = "patch"
  879. )
  880. func (r PartType) IsKnown() bool {
  881. switch r {
  882. case PartTypeText, PartTypeFile, PartTypeTool, PartTypeStepStart, PartTypeStepFinish, PartTypeSnapshot, PartTypePatch:
  883. return true
  884. }
  885. return false
  886. }
  887. type Session struct {
  888. ID string `json:"id,required"`
  889. Time SessionTime `json:"time,required"`
  890. Title string `json:"title,required"`
  891. Version string `json:"version,required"`
  892. ParentID string `json:"parentID"`
  893. Revert SessionRevert `json:"revert"`
  894. Share SessionShare `json:"share"`
  895. JSON sessionJSON `json:"-"`
  896. }
  897. // sessionJSON contains the JSON metadata for the struct [Session]
  898. type sessionJSON struct {
  899. ID apijson.Field
  900. Time apijson.Field
  901. Title apijson.Field
  902. Version apijson.Field
  903. ParentID apijson.Field
  904. Revert apijson.Field
  905. Share apijson.Field
  906. raw string
  907. ExtraFields map[string]apijson.Field
  908. }
  909. func (r *Session) UnmarshalJSON(data []byte) (err error) {
  910. return apijson.UnmarshalRoot(data, r)
  911. }
  912. func (r sessionJSON) RawJSON() string {
  913. return r.raw
  914. }
  915. type SessionTime struct {
  916. Created float64 `json:"created,required"`
  917. Updated float64 `json:"updated,required"`
  918. JSON sessionTimeJSON `json:"-"`
  919. }
  920. // sessionTimeJSON contains the JSON metadata for the struct [SessionTime]
  921. type sessionTimeJSON struct {
  922. Created apijson.Field
  923. Updated apijson.Field
  924. raw string
  925. ExtraFields map[string]apijson.Field
  926. }
  927. func (r *SessionTime) UnmarshalJSON(data []byte) (err error) {
  928. return apijson.UnmarshalRoot(data, r)
  929. }
  930. func (r sessionTimeJSON) RawJSON() string {
  931. return r.raw
  932. }
  933. type SessionRevert struct {
  934. MessageID string `json:"messageID,required"`
  935. PartID string `json:"partID"`
  936. Snapshot string `json:"snapshot"`
  937. JSON sessionRevertJSON `json:"-"`
  938. }
  939. // sessionRevertJSON contains the JSON metadata for the struct [SessionRevert]
  940. type sessionRevertJSON struct {
  941. MessageID apijson.Field
  942. PartID apijson.Field
  943. Snapshot apijson.Field
  944. raw string
  945. ExtraFields map[string]apijson.Field
  946. }
  947. func (r *SessionRevert) UnmarshalJSON(data []byte) (err error) {
  948. return apijson.UnmarshalRoot(data, r)
  949. }
  950. func (r sessionRevertJSON) RawJSON() string {
  951. return r.raw
  952. }
  953. type SessionShare struct {
  954. URL string `json:"url,required"`
  955. JSON sessionShareJSON `json:"-"`
  956. }
  957. // sessionShareJSON contains the JSON metadata for the struct [SessionShare]
  958. type sessionShareJSON struct {
  959. URL apijson.Field
  960. raw string
  961. ExtraFields map[string]apijson.Field
  962. }
  963. func (r *SessionShare) UnmarshalJSON(data []byte) (err error) {
  964. return apijson.UnmarshalRoot(data, r)
  965. }
  966. func (r sessionShareJSON) RawJSON() string {
  967. return r.raw
  968. }
  969. type SnapshotPart struct {
  970. ID string `json:"id,required"`
  971. MessageID string `json:"messageID,required"`
  972. SessionID string `json:"sessionID,required"`
  973. Snapshot string `json:"snapshot,required"`
  974. Type SnapshotPartType `json:"type,required"`
  975. JSON snapshotPartJSON `json:"-"`
  976. }
  977. // snapshotPartJSON contains the JSON metadata for the struct [SnapshotPart]
  978. type snapshotPartJSON struct {
  979. ID apijson.Field
  980. MessageID apijson.Field
  981. SessionID apijson.Field
  982. Snapshot apijson.Field
  983. Type apijson.Field
  984. raw string
  985. ExtraFields map[string]apijson.Field
  986. }
  987. func (r *SnapshotPart) UnmarshalJSON(data []byte) (err error) {
  988. return apijson.UnmarshalRoot(data, r)
  989. }
  990. func (r snapshotPartJSON) RawJSON() string {
  991. return r.raw
  992. }
  993. func (r SnapshotPart) implementsPart() {}
  994. type SnapshotPartType string
  995. const (
  996. SnapshotPartTypeSnapshot SnapshotPartType = "snapshot"
  997. )
  998. func (r SnapshotPartType) IsKnown() bool {
  999. switch r {
  1000. case SnapshotPartTypeSnapshot:
  1001. return true
  1002. }
  1003. return false
  1004. }
  1005. type StepFinishPart struct {
  1006. ID string `json:"id,required"`
  1007. Cost float64 `json:"cost,required"`
  1008. MessageID string `json:"messageID,required"`
  1009. SessionID string `json:"sessionID,required"`
  1010. Tokens StepFinishPartTokens `json:"tokens,required"`
  1011. Type StepFinishPartType `json:"type,required"`
  1012. JSON stepFinishPartJSON `json:"-"`
  1013. }
  1014. // stepFinishPartJSON contains the JSON metadata for the struct [StepFinishPart]
  1015. type stepFinishPartJSON struct {
  1016. ID apijson.Field
  1017. Cost apijson.Field
  1018. MessageID apijson.Field
  1019. SessionID apijson.Field
  1020. Tokens apijson.Field
  1021. Type apijson.Field
  1022. raw string
  1023. ExtraFields map[string]apijson.Field
  1024. }
  1025. func (r *StepFinishPart) UnmarshalJSON(data []byte) (err error) {
  1026. return apijson.UnmarshalRoot(data, r)
  1027. }
  1028. func (r stepFinishPartJSON) RawJSON() string {
  1029. return r.raw
  1030. }
  1031. func (r StepFinishPart) implementsPart() {}
  1032. type StepFinishPartTokens struct {
  1033. Cache StepFinishPartTokensCache `json:"cache,required"`
  1034. Input float64 `json:"input,required"`
  1035. Output float64 `json:"output,required"`
  1036. Reasoning float64 `json:"reasoning,required"`
  1037. JSON stepFinishPartTokensJSON `json:"-"`
  1038. }
  1039. // stepFinishPartTokensJSON contains the JSON metadata for the struct
  1040. // [StepFinishPartTokens]
  1041. type stepFinishPartTokensJSON struct {
  1042. Cache apijson.Field
  1043. Input apijson.Field
  1044. Output apijson.Field
  1045. Reasoning apijson.Field
  1046. raw string
  1047. ExtraFields map[string]apijson.Field
  1048. }
  1049. func (r *StepFinishPartTokens) UnmarshalJSON(data []byte) (err error) {
  1050. return apijson.UnmarshalRoot(data, r)
  1051. }
  1052. func (r stepFinishPartTokensJSON) RawJSON() string {
  1053. return r.raw
  1054. }
  1055. type StepFinishPartTokensCache struct {
  1056. Read float64 `json:"read,required"`
  1057. Write float64 `json:"write,required"`
  1058. JSON stepFinishPartTokensCacheJSON `json:"-"`
  1059. }
  1060. // stepFinishPartTokensCacheJSON contains the JSON metadata for the struct
  1061. // [StepFinishPartTokensCache]
  1062. type stepFinishPartTokensCacheJSON struct {
  1063. Read apijson.Field
  1064. Write apijson.Field
  1065. raw string
  1066. ExtraFields map[string]apijson.Field
  1067. }
  1068. func (r *StepFinishPartTokensCache) UnmarshalJSON(data []byte) (err error) {
  1069. return apijson.UnmarshalRoot(data, r)
  1070. }
  1071. func (r stepFinishPartTokensCacheJSON) RawJSON() string {
  1072. return r.raw
  1073. }
  1074. type StepFinishPartType string
  1075. const (
  1076. StepFinishPartTypeStepFinish StepFinishPartType = "step-finish"
  1077. )
  1078. func (r StepFinishPartType) IsKnown() bool {
  1079. switch r {
  1080. case StepFinishPartTypeStepFinish:
  1081. return true
  1082. }
  1083. return false
  1084. }
  1085. type StepStartPart struct {
  1086. ID string `json:"id,required"`
  1087. MessageID string `json:"messageID,required"`
  1088. SessionID string `json:"sessionID,required"`
  1089. Type StepStartPartType `json:"type,required"`
  1090. JSON stepStartPartJSON `json:"-"`
  1091. }
  1092. // stepStartPartJSON contains the JSON metadata for the struct [StepStartPart]
  1093. type stepStartPartJSON struct {
  1094. ID apijson.Field
  1095. MessageID apijson.Field
  1096. SessionID apijson.Field
  1097. Type apijson.Field
  1098. raw string
  1099. ExtraFields map[string]apijson.Field
  1100. }
  1101. func (r *StepStartPart) UnmarshalJSON(data []byte) (err error) {
  1102. return apijson.UnmarshalRoot(data, r)
  1103. }
  1104. func (r stepStartPartJSON) RawJSON() string {
  1105. return r.raw
  1106. }
  1107. func (r StepStartPart) implementsPart() {}
  1108. type StepStartPartType string
  1109. const (
  1110. StepStartPartTypeStepStart StepStartPartType = "step-start"
  1111. )
  1112. func (r StepStartPartType) IsKnown() bool {
  1113. switch r {
  1114. case StepStartPartTypeStepStart:
  1115. return true
  1116. }
  1117. return false
  1118. }
  1119. type SymbolSource struct {
  1120. Kind int64 `json:"kind,required"`
  1121. Name string `json:"name,required"`
  1122. Path string `json:"path,required"`
  1123. Range SymbolSourceRange `json:"range,required"`
  1124. Text FilePartSourceText `json:"text,required"`
  1125. Type SymbolSourceType `json:"type,required"`
  1126. JSON symbolSourceJSON `json:"-"`
  1127. }
  1128. // symbolSourceJSON contains the JSON metadata for the struct [SymbolSource]
  1129. type symbolSourceJSON struct {
  1130. Kind apijson.Field
  1131. Name apijson.Field
  1132. Path apijson.Field
  1133. Range apijson.Field
  1134. Text apijson.Field
  1135. Type apijson.Field
  1136. raw string
  1137. ExtraFields map[string]apijson.Field
  1138. }
  1139. func (r *SymbolSource) UnmarshalJSON(data []byte) (err error) {
  1140. return apijson.UnmarshalRoot(data, r)
  1141. }
  1142. func (r symbolSourceJSON) RawJSON() string {
  1143. return r.raw
  1144. }
  1145. func (r SymbolSource) implementsFilePartSource() {}
  1146. type SymbolSourceRange struct {
  1147. End SymbolSourceRangeEnd `json:"end,required"`
  1148. Start SymbolSourceRangeStart `json:"start,required"`
  1149. JSON symbolSourceRangeJSON `json:"-"`
  1150. }
  1151. // symbolSourceRangeJSON contains the JSON metadata for the struct
  1152. // [SymbolSourceRange]
  1153. type symbolSourceRangeJSON struct {
  1154. End apijson.Field
  1155. Start apijson.Field
  1156. raw string
  1157. ExtraFields map[string]apijson.Field
  1158. }
  1159. func (r *SymbolSourceRange) UnmarshalJSON(data []byte) (err error) {
  1160. return apijson.UnmarshalRoot(data, r)
  1161. }
  1162. func (r symbolSourceRangeJSON) RawJSON() string {
  1163. return r.raw
  1164. }
  1165. type SymbolSourceRangeEnd struct {
  1166. Character float64 `json:"character,required"`
  1167. Line float64 `json:"line,required"`
  1168. JSON symbolSourceRangeEndJSON `json:"-"`
  1169. }
  1170. // symbolSourceRangeEndJSON contains the JSON metadata for the struct
  1171. // [SymbolSourceRangeEnd]
  1172. type symbolSourceRangeEndJSON struct {
  1173. Character apijson.Field
  1174. Line apijson.Field
  1175. raw string
  1176. ExtraFields map[string]apijson.Field
  1177. }
  1178. func (r *SymbolSourceRangeEnd) UnmarshalJSON(data []byte) (err error) {
  1179. return apijson.UnmarshalRoot(data, r)
  1180. }
  1181. func (r symbolSourceRangeEndJSON) RawJSON() string {
  1182. return r.raw
  1183. }
  1184. type SymbolSourceRangeStart struct {
  1185. Character float64 `json:"character,required"`
  1186. Line float64 `json:"line,required"`
  1187. JSON symbolSourceRangeStartJSON `json:"-"`
  1188. }
  1189. // symbolSourceRangeStartJSON contains the JSON metadata for the struct
  1190. // [SymbolSourceRangeStart]
  1191. type symbolSourceRangeStartJSON struct {
  1192. Character apijson.Field
  1193. Line apijson.Field
  1194. raw string
  1195. ExtraFields map[string]apijson.Field
  1196. }
  1197. func (r *SymbolSourceRangeStart) UnmarshalJSON(data []byte) (err error) {
  1198. return apijson.UnmarshalRoot(data, r)
  1199. }
  1200. func (r symbolSourceRangeStartJSON) RawJSON() string {
  1201. return r.raw
  1202. }
  1203. type SymbolSourceType string
  1204. const (
  1205. SymbolSourceTypeSymbol SymbolSourceType = "symbol"
  1206. )
  1207. func (r SymbolSourceType) IsKnown() bool {
  1208. switch r {
  1209. case SymbolSourceTypeSymbol:
  1210. return true
  1211. }
  1212. return false
  1213. }
  1214. type SymbolSourceParam struct {
  1215. Kind param.Field[int64] `json:"kind,required"`
  1216. Name param.Field[string] `json:"name,required"`
  1217. Path param.Field[string] `json:"path,required"`
  1218. Range param.Field[SymbolSourceRangeParam] `json:"range,required"`
  1219. Text param.Field[FilePartSourceTextParam] `json:"text,required"`
  1220. Type param.Field[SymbolSourceType] `json:"type,required"`
  1221. }
  1222. func (r SymbolSourceParam) MarshalJSON() (data []byte, err error) {
  1223. return apijson.MarshalRoot(r)
  1224. }
  1225. func (r SymbolSourceParam) implementsFilePartSourceUnionParam() {}
  1226. type SymbolSourceRangeParam struct {
  1227. End param.Field[SymbolSourceRangeEndParam] `json:"end,required"`
  1228. Start param.Field[SymbolSourceRangeStartParam] `json:"start,required"`
  1229. }
  1230. func (r SymbolSourceRangeParam) MarshalJSON() (data []byte, err error) {
  1231. return apijson.MarshalRoot(r)
  1232. }
  1233. type SymbolSourceRangeEndParam struct {
  1234. Character param.Field[float64] `json:"character,required"`
  1235. Line param.Field[float64] `json:"line,required"`
  1236. }
  1237. func (r SymbolSourceRangeEndParam) MarshalJSON() (data []byte, err error) {
  1238. return apijson.MarshalRoot(r)
  1239. }
  1240. type SymbolSourceRangeStartParam struct {
  1241. Character param.Field[float64] `json:"character,required"`
  1242. Line param.Field[float64] `json:"line,required"`
  1243. }
  1244. func (r SymbolSourceRangeStartParam) MarshalJSON() (data []byte, err error) {
  1245. return apijson.MarshalRoot(r)
  1246. }
  1247. type TextPart struct {
  1248. ID string `json:"id,required"`
  1249. MessageID string `json:"messageID,required"`
  1250. SessionID string `json:"sessionID,required"`
  1251. Text string `json:"text,required"`
  1252. Type TextPartType `json:"type,required"`
  1253. Synthetic bool `json:"synthetic"`
  1254. Time TextPartTime `json:"time"`
  1255. JSON textPartJSON `json:"-"`
  1256. }
  1257. // textPartJSON contains the JSON metadata for the struct [TextPart]
  1258. type textPartJSON struct {
  1259. ID apijson.Field
  1260. MessageID apijson.Field
  1261. SessionID apijson.Field
  1262. Text apijson.Field
  1263. Type apijson.Field
  1264. Synthetic apijson.Field
  1265. Time apijson.Field
  1266. raw string
  1267. ExtraFields map[string]apijson.Field
  1268. }
  1269. func (r *TextPart) UnmarshalJSON(data []byte) (err error) {
  1270. return apijson.UnmarshalRoot(data, r)
  1271. }
  1272. func (r textPartJSON) RawJSON() string {
  1273. return r.raw
  1274. }
  1275. func (r TextPart) implementsPart() {}
  1276. type TextPartType string
  1277. const (
  1278. TextPartTypeText TextPartType = "text"
  1279. )
  1280. func (r TextPartType) IsKnown() bool {
  1281. switch r {
  1282. case TextPartTypeText:
  1283. return true
  1284. }
  1285. return false
  1286. }
  1287. type TextPartTime struct {
  1288. Start float64 `json:"start,required"`
  1289. End float64 `json:"end"`
  1290. JSON textPartTimeJSON `json:"-"`
  1291. }
  1292. // textPartTimeJSON contains the JSON metadata for the struct [TextPartTime]
  1293. type textPartTimeJSON struct {
  1294. Start apijson.Field
  1295. End apijson.Field
  1296. raw string
  1297. ExtraFields map[string]apijson.Field
  1298. }
  1299. func (r *TextPartTime) UnmarshalJSON(data []byte) (err error) {
  1300. return apijson.UnmarshalRoot(data, r)
  1301. }
  1302. func (r textPartTimeJSON) RawJSON() string {
  1303. return r.raw
  1304. }
  1305. type TextPartInputParam struct {
  1306. Text param.Field[string] `json:"text,required"`
  1307. Type param.Field[TextPartInputType] `json:"type,required"`
  1308. ID param.Field[string] `json:"id"`
  1309. Synthetic param.Field[bool] `json:"synthetic"`
  1310. Time param.Field[TextPartInputTimeParam] `json:"time"`
  1311. }
  1312. func (r TextPartInputParam) MarshalJSON() (data []byte, err error) {
  1313. return apijson.MarshalRoot(r)
  1314. }
  1315. func (r TextPartInputParam) implementsSessionChatParamsPartUnion() {}
  1316. type TextPartInputType string
  1317. const (
  1318. TextPartInputTypeText TextPartInputType = "text"
  1319. )
  1320. func (r TextPartInputType) IsKnown() bool {
  1321. switch r {
  1322. case TextPartInputTypeText:
  1323. return true
  1324. }
  1325. return false
  1326. }
  1327. type TextPartInputTimeParam struct {
  1328. Start param.Field[float64] `json:"start,required"`
  1329. End param.Field[float64] `json:"end"`
  1330. }
  1331. func (r TextPartInputTimeParam) MarshalJSON() (data []byte, err error) {
  1332. return apijson.MarshalRoot(r)
  1333. }
  1334. type ToolPart struct {
  1335. ID string `json:"id,required"`
  1336. CallID string `json:"callID,required"`
  1337. MessageID string `json:"messageID,required"`
  1338. SessionID string `json:"sessionID,required"`
  1339. State ToolPartState `json:"state,required"`
  1340. Tool string `json:"tool,required"`
  1341. Type ToolPartType `json:"type,required"`
  1342. JSON toolPartJSON `json:"-"`
  1343. }
  1344. // toolPartJSON contains the JSON metadata for the struct [ToolPart]
  1345. type toolPartJSON struct {
  1346. ID apijson.Field
  1347. CallID apijson.Field
  1348. MessageID apijson.Field
  1349. SessionID apijson.Field
  1350. State apijson.Field
  1351. Tool apijson.Field
  1352. Type apijson.Field
  1353. raw string
  1354. ExtraFields map[string]apijson.Field
  1355. }
  1356. func (r *ToolPart) UnmarshalJSON(data []byte) (err error) {
  1357. return apijson.UnmarshalRoot(data, r)
  1358. }
  1359. func (r toolPartJSON) RawJSON() string {
  1360. return r.raw
  1361. }
  1362. func (r ToolPart) implementsPart() {}
  1363. type ToolPartState struct {
  1364. Status ToolPartStateStatus `json:"status,required"`
  1365. Error string `json:"error"`
  1366. // This field can have the runtime type of [interface{}], [map[string]interface{}].
  1367. Input interface{} `json:"input"`
  1368. // This field can have the runtime type of [map[string]interface{}].
  1369. Metadata interface{} `json:"metadata"`
  1370. Output string `json:"output"`
  1371. // This field can have the runtime type of [ToolStateRunningTime],
  1372. // [ToolStateCompletedTime], [ToolStateErrorTime].
  1373. Time interface{} `json:"time"`
  1374. Title string `json:"title"`
  1375. JSON toolPartStateJSON `json:"-"`
  1376. union ToolPartStateUnion
  1377. }
  1378. // toolPartStateJSON contains the JSON metadata for the struct [ToolPartState]
  1379. type toolPartStateJSON struct {
  1380. Status apijson.Field
  1381. Error apijson.Field
  1382. Input apijson.Field
  1383. Metadata apijson.Field
  1384. Output apijson.Field
  1385. Time apijson.Field
  1386. Title apijson.Field
  1387. raw string
  1388. ExtraFields map[string]apijson.Field
  1389. }
  1390. func (r toolPartStateJSON) RawJSON() string {
  1391. return r.raw
  1392. }
  1393. func (r *ToolPartState) UnmarshalJSON(data []byte) (err error) {
  1394. *r = ToolPartState{}
  1395. err = apijson.UnmarshalRoot(data, &r.union)
  1396. if err != nil {
  1397. return err
  1398. }
  1399. return apijson.Port(r.union, &r)
  1400. }
  1401. // AsUnion returns a [ToolPartStateUnion] interface which you can cast to the
  1402. // specific types for more type safety.
  1403. //
  1404. // Possible runtime types of the union are [ToolStatePending], [ToolStateRunning],
  1405. // [ToolStateCompleted], [ToolStateError].
  1406. func (r ToolPartState) AsUnion() ToolPartStateUnion {
  1407. return r.union
  1408. }
  1409. // Union satisfied by [ToolStatePending], [ToolStateRunning], [ToolStateCompleted]
  1410. // or [ToolStateError].
  1411. type ToolPartStateUnion interface {
  1412. implementsToolPartState()
  1413. }
  1414. func init() {
  1415. apijson.RegisterUnion(
  1416. reflect.TypeOf((*ToolPartStateUnion)(nil)).Elem(),
  1417. "status",
  1418. apijson.UnionVariant{
  1419. TypeFilter: gjson.JSON,
  1420. Type: reflect.TypeOf(ToolStatePending{}),
  1421. DiscriminatorValue: "pending",
  1422. },
  1423. apijson.UnionVariant{
  1424. TypeFilter: gjson.JSON,
  1425. Type: reflect.TypeOf(ToolStateRunning{}),
  1426. DiscriminatorValue: "running",
  1427. },
  1428. apijson.UnionVariant{
  1429. TypeFilter: gjson.JSON,
  1430. Type: reflect.TypeOf(ToolStateCompleted{}),
  1431. DiscriminatorValue: "completed",
  1432. },
  1433. apijson.UnionVariant{
  1434. TypeFilter: gjson.JSON,
  1435. Type: reflect.TypeOf(ToolStateError{}),
  1436. DiscriminatorValue: "error",
  1437. },
  1438. )
  1439. }
  1440. type ToolPartStateStatus string
  1441. const (
  1442. ToolPartStateStatusPending ToolPartStateStatus = "pending"
  1443. ToolPartStateStatusRunning ToolPartStateStatus = "running"
  1444. ToolPartStateStatusCompleted ToolPartStateStatus = "completed"
  1445. ToolPartStateStatusError ToolPartStateStatus = "error"
  1446. )
  1447. func (r ToolPartStateStatus) IsKnown() bool {
  1448. switch r {
  1449. case ToolPartStateStatusPending, ToolPartStateStatusRunning, ToolPartStateStatusCompleted, ToolPartStateStatusError:
  1450. return true
  1451. }
  1452. return false
  1453. }
  1454. type ToolPartType string
  1455. const (
  1456. ToolPartTypeTool ToolPartType = "tool"
  1457. )
  1458. func (r ToolPartType) IsKnown() bool {
  1459. switch r {
  1460. case ToolPartTypeTool:
  1461. return true
  1462. }
  1463. return false
  1464. }
  1465. type ToolStateCompleted struct {
  1466. Input map[string]interface{} `json:"input,required"`
  1467. Metadata map[string]interface{} `json:"metadata,required"`
  1468. Output string `json:"output,required"`
  1469. Status ToolStateCompletedStatus `json:"status,required"`
  1470. Time ToolStateCompletedTime `json:"time,required"`
  1471. Title string `json:"title,required"`
  1472. JSON toolStateCompletedJSON `json:"-"`
  1473. }
  1474. // toolStateCompletedJSON contains the JSON metadata for the struct
  1475. // [ToolStateCompleted]
  1476. type toolStateCompletedJSON struct {
  1477. Input apijson.Field
  1478. Metadata apijson.Field
  1479. Output apijson.Field
  1480. Status apijson.Field
  1481. Time apijson.Field
  1482. Title apijson.Field
  1483. raw string
  1484. ExtraFields map[string]apijson.Field
  1485. }
  1486. func (r *ToolStateCompleted) UnmarshalJSON(data []byte) (err error) {
  1487. return apijson.UnmarshalRoot(data, r)
  1488. }
  1489. func (r toolStateCompletedJSON) RawJSON() string {
  1490. return r.raw
  1491. }
  1492. func (r ToolStateCompleted) implementsToolPartState() {}
  1493. type ToolStateCompletedStatus string
  1494. const (
  1495. ToolStateCompletedStatusCompleted ToolStateCompletedStatus = "completed"
  1496. )
  1497. func (r ToolStateCompletedStatus) IsKnown() bool {
  1498. switch r {
  1499. case ToolStateCompletedStatusCompleted:
  1500. return true
  1501. }
  1502. return false
  1503. }
  1504. type ToolStateCompletedTime struct {
  1505. End float64 `json:"end,required"`
  1506. Start float64 `json:"start,required"`
  1507. JSON toolStateCompletedTimeJSON `json:"-"`
  1508. }
  1509. // toolStateCompletedTimeJSON contains the JSON metadata for the struct
  1510. // [ToolStateCompletedTime]
  1511. type toolStateCompletedTimeJSON struct {
  1512. End apijson.Field
  1513. Start apijson.Field
  1514. raw string
  1515. ExtraFields map[string]apijson.Field
  1516. }
  1517. func (r *ToolStateCompletedTime) UnmarshalJSON(data []byte) (err error) {
  1518. return apijson.UnmarshalRoot(data, r)
  1519. }
  1520. func (r toolStateCompletedTimeJSON) RawJSON() string {
  1521. return r.raw
  1522. }
  1523. type ToolStateError struct {
  1524. Error string `json:"error,required"`
  1525. Input map[string]interface{} `json:"input,required"`
  1526. Status ToolStateErrorStatus `json:"status,required"`
  1527. Time ToolStateErrorTime `json:"time,required"`
  1528. JSON toolStateErrorJSON `json:"-"`
  1529. }
  1530. // toolStateErrorJSON contains the JSON metadata for the struct [ToolStateError]
  1531. type toolStateErrorJSON struct {
  1532. Error apijson.Field
  1533. Input apijson.Field
  1534. Status apijson.Field
  1535. Time apijson.Field
  1536. raw string
  1537. ExtraFields map[string]apijson.Field
  1538. }
  1539. func (r *ToolStateError) UnmarshalJSON(data []byte) (err error) {
  1540. return apijson.UnmarshalRoot(data, r)
  1541. }
  1542. func (r toolStateErrorJSON) RawJSON() string {
  1543. return r.raw
  1544. }
  1545. func (r ToolStateError) implementsToolPartState() {}
  1546. type ToolStateErrorStatus string
  1547. const (
  1548. ToolStateErrorStatusError ToolStateErrorStatus = "error"
  1549. )
  1550. func (r ToolStateErrorStatus) IsKnown() bool {
  1551. switch r {
  1552. case ToolStateErrorStatusError:
  1553. return true
  1554. }
  1555. return false
  1556. }
  1557. type ToolStateErrorTime struct {
  1558. End float64 `json:"end,required"`
  1559. Start float64 `json:"start,required"`
  1560. JSON toolStateErrorTimeJSON `json:"-"`
  1561. }
  1562. // toolStateErrorTimeJSON contains the JSON metadata for the struct
  1563. // [ToolStateErrorTime]
  1564. type toolStateErrorTimeJSON struct {
  1565. End apijson.Field
  1566. Start apijson.Field
  1567. raw string
  1568. ExtraFields map[string]apijson.Field
  1569. }
  1570. func (r *ToolStateErrorTime) UnmarshalJSON(data []byte) (err error) {
  1571. return apijson.UnmarshalRoot(data, r)
  1572. }
  1573. func (r toolStateErrorTimeJSON) RawJSON() string {
  1574. return r.raw
  1575. }
  1576. type ToolStatePending struct {
  1577. Status ToolStatePendingStatus `json:"status,required"`
  1578. JSON toolStatePendingJSON `json:"-"`
  1579. }
  1580. // toolStatePendingJSON contains the JSON metadata for the struct
  1581. // [ToolStatePending]
  1582. type toolStatePendingJSON struct {
  1583. Status apijson.Field
  1584. raw string
  1585. ExtraFields map[string]apijson.Field
  1586. }
  1587. func (r *ToolStatePending) UnmarshalJSON(data []byte) (err error) {
  1588. return apijson.UnmarshalRoot(data, r)
  1589. }
  1590. func (r toolStatePendingJSON) RawJSON() string {
  1591. return r.raw
  1592. }
  1593. func (r ToolStatePending) implementsToolPartState() {}
  1594. type ToolStatePendingStatus string
  1595. const (
  1596. ToolStatePendingStatusPending ToolStatePendingStatus = "pending"
  1597. )
  1598. func (r ToolStatePendingStatus) IsKnown() bool {
  1599. switch r {
  1600. case ToolStatePendingStatusPending:
  1601. return true
  1602. }
  1603. return false
  1604. }
  1605. type ToolStateRunning struct {
  1606. Status ToolStateRunningStatus `json:"status,required"`
  1607. Time ToolStateRunningTime `json:"time,required"`
  1608. Input interface{} `json:"input"`
  1609. Metadata map[string]interface{} `json:"metadata"`
  1610. Title string `json:"title"`
  1611. JSON toolStateRunningJSON `json:"-"`
  1612. }
  1613. // toolStateRunningJSON contains the JSON metadata for the struct
  1614. // [ToolStateRunning]
  1615. type toolStateRunningJSON struct {
  1616. Status apijson.Field
  1617. Time apijson.Field
  1618. Input apijson.Field
  1619. Metadata apijson.Field
  1620. Title apijson.Field
  1621. raw string
  1622. ExtraFields map[string]apijson.Field
  1623. }
  1624. func (r *ToolStateRunning) UnmarshalJSON(data []byte) (err error) {
  1625. return apijson.UnmarshalRoot(data, r)
  1626. }
  1627. func (r toolStateRunningJSON) RawJSON() string {
  1628. return r.raw
  1629. }
  1630. func (r ToolStateRunning) implementsToolPartState() {}
  1631. type ToolStateRunningStatus string
  1632. const (
  1633. ToolStateRunningStatusRunning ToolStateRunningStatus = "running"
  1634. )
  1635. func (r ToolStateRunningStatus) IsKnown() bool {
  1636. switch r {
  1637. case ToolStateRunningStatusRunning:
  1638. return true
  1639. }
  1640. return false
  1641. }
  1642. type ToolStateRunningTime struct {
  1643. Start float64 `json:"start,required"`
  1644. JSON toolStateRunningTimeJSON `json:"-"`
  1645. }
  1646. // toolStateRunningTimeJSON contains the JSON metadata for the struct
  1647. // [ToolStateRunningTime]
  1648. type toolStateRunningTimeJSON struct {
  1649. Start apijson.Field
  1650. raw string
  1651. ExtraFields map[string]apijson.Field
  1652. }
  1653. func (r *ToolStateRunningTime) UnmarshalJSON(data []byte) (err error) {
  1654. return apijson.UnmarshalRoot(data, r)
  1655. }
  1656. func (r toolStateRunningTimeJSON) RawJSON() string {
  1657. return r.raw
  1658. }
  1659. type UserMessage struct {
  1660. ID string `json:"id,required"`
  1661. Role UserMessageRole `json:"role,required"`
  1662. SessionID string `json:"sessionID,required"`
  1663. Time UserMessageTime `json:"time,required"`
  1664. JSON userMessageJSON `json:"-"`
  1665. }
  1666. // userMessageJSON contains the JSON metadata for the struct [UserMessage]
  1667. type userMessageJSON struct {
  1668. ID apijson.Field
  1669. Role apijson.Field
  1670. SessionID apijson.Field
  1671. Time apijson.Field
  1672. raw string
  1673. ExtraFields map[string]apijson.Field
  1674. }
  1675. func (r *UserMessage) UnmarshalJSON(data []byte) (err error) {
  1676. return apijson.UnmarshalRoot(data, r)
  1677. }
  1678. func (r userMessageJSON) RawJSON() string {
  1679. return r.raw
  1680. }
  1681. func (r UserMessage) implementsMessage() {}
  1682. type UserMessageRole string
  1683. const (
  1684. UserMessageRoleUser UserMessageRole = "user"
  1685. )
  1686. func (r UserMessageRole) IsKnown() bool {
  1687. switch r {
  1688. case UserMessageRoleUser:
  1689. return true
  1690. }
  1691. return false
  1692. }
  1693. type UserMessageTime struct {
  1694. Created float64 `json:"created,required"`
  1695. JSON userMessageTimeJSON `json:"-"`
  1696. }
  1697. // userMessageTimeJSON contains the JSON metadata for the struct [UserMessageTime]
  1698. type userMessageTimeJSON struct {
  1699. Created apijson.Field
  1700. raw string
  1701. ExtraFields map[string]apijson.Field
  1702. }
  1703. func (r *UserMessageTime) UnmarshalJSON(data []byte) (err error) {
  1704. return apijson.UnmarshalRoot(data, r)
  1705. }
  1706. func (r userMessageTimeJSON) RawJSON() string {
  1707. return r.raw
  1708. }
  1709. type SessionMessagesResponse struct {
  1710. Info Message `json:"info,required"`
  1711. Parts []Part `json:"parts,required"`
  1712. JSON sessionMessagesResponseJSON `json:"-"`
  1713. }
  1714. // sessionMessagesResponseJSON contains the JSON metadata for the struct
  1715. // [SessionMessagesResponse]
  1716. type sessionMessagesResponseJSON struct {
  1717. Info apijson.Field
  1718. Parts apijson.Field
  1719. raw string
  1720. ExtraFields map[string]apijson.Field
  1721. }
  1722. func (r *SessionMessagesResponse) UnmarshalJSON(data []byte) (err error) {
  1723. return apijson.UnmarshalRoot(data, r)
  1724. }
  1725. func (r sessionMessagesResponseJSON) RawJSON() string {
  1726. return r.raw
  1727. }
  1728. type SessionChatParams struct {
  1729. ModelID param.Field[string] `json:"modelID,required"`
  1730. Parts param.Field[[]SessionChatParamsPartUnion] `json:"parts,required"`
  1731. ProviderID param.Field[string] `json:"providerID,required"`
  1732. MessageID param.Field[string] `json:"messageID"`
  1733. Mode param.Field[string] `json:"mode"`
  1734. Tools param.Field[map[string]bool] `json:"tools"`
  1735. }
  1736. func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
  1737. return apijson.MarshalRoot(r)
  1738. }
  1739. type SessionChatParamsPart struct {
  1740. Type param.Field[SessionChatParamsPartsType] `json:"type,required"`
  1741. ID param.Field[string] `json:"id"`
  1742. Filename param.Field[string] `json:"filename"`
  1743. Mime param.Field[string] `json:"mime"`
  1744. Source param.Field[FilePartSourceUnionParam] `json:"source"`
  1745. Synthetic param.Field[bool] `json:"synthetic"`
  1746. Text param.Field[string] `json:"text"`
  1747. Time param.Field[interface{}] `json:"time"`
  1748. URL param.Field[string] `json:"url"`
  1749. }
  1750. func (r SessionChatParamsPart) MarshalJSON() (data []byte, err error) {
  1751. return apijson.MarshalRoot(r)
  1752. }
  1753. func (r SessionChatParamsPart) implementsSessionChatParamsPartUnion() {}
  1754. // Satisfied by [TextPartInputParam], [FilePartInputParam],
  1755. // [SessionChatParamsPart].
  1756. type SessionChatParamsPartUnion interface {
  1757. implementsSessionChatParamsPartUnion()
  1758. }
  1759. type SessionChatParamsPartsType string
  1760. const (
  1761. SessionChatParamsPartsTypeText SessionChatParamsPartsType = "text"
  1762. SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
  1763. )
  1764. func (r SessionChatParamsPartsType) IsKnown() bool {
  1765. switch r {
  1766. case SessionChatParamsPartsTypeText, SessionChatParamsPartsTypeFile:
  1767. return true
  1768. }
  1769. return false
  1770. }
  1771. type SessionInitParams struct {
  1772. MessageID param.Field[string] `json:"messageID,required"`
  1773. ModelID param.Field[string] `json:"modelID,required"`
  1774. ProviderID param.Field[string] `json:"providerID,required"`
  1775. }
  1776. func (r SessionInitParams) MarshalJSON() (data []byte, err error) {
  1777. return apijson.MarshalRoot(r)
  1778. }
  1779. type SessionRevertParams struct {
  1780. MessageID param.Field[string] `json:"messageID,required"`
  1781. PartID param.Field[string] `json:"partID"`
  1782. }
  1783. func (r SessionRevertParams) MarshalJSON() (data []byte, err error) {
  1784. return apijson.MarshalRoot(r)
  1785. }
  1786. type SessionSummarizeParams struct {
  1787. ModelID param.Field[string] `json:"modelID,required"`
  1788. ProviderID param.Field[string] `json:"providerID,required"`
  1789. }
  1790. func (r SessionSummarizeParams) MarshalJSON() (data []byte, err error) {
  1791. return apijson.MarshalRoot(r)
  1792. }