session.go 63 KB

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