session.go 76 KB

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