config.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. package opencode
  3. import (
  4. "context"
  5. "net/http"
  6. "reflect"
  7. "github.com/sst/opencode-sdk-go/internal/apijson"
  8. "github.com/sst/opencode-sdk-go/internal/requestconfig"
  9. "github.com/sst/opencode-sdk-go/option"
  10. "github.com/tidwall/gjson"
  11. )
  12. // ConfigService contains methods and other services that help with interacting
  13. // with the opencode API.
  14. //
  15. // Note, unlike clients, this service does not read variables from the environment
  16. // automatically. You should not instantiate this service directly, and instead use
  17. // the [NewConfigService] method instead.
  18. type ConfigService struct {
  19. Options []option.RequestOption
  20. }
  21. // NewConfigService generates a new service that applies the given options to each
  22. // request. These options are applied after the parent client's options (if there
  23. // is one), and before any request-specific options.
  24. func NewConfigService(opts ...option.RequestOption) (r *ConfigService) {
  25. r = &ConfigService{}
  26. r.Options = opts
  27. return
  28. }
  29. // Get config info
  30. func (r *ConfigService) Get(ctx context.Context, opts ...option.RequestOption) (res *Config, err error) {
  31. opts = append(r.Options[:], opts...)
  32. path := "config"
  33. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  34. return
  35. }
  36. // List all providers
  37. func (r *ConfigService) Providers(ctx context.Context, opts ...option.RequestOption) (res *ConfigProvidersResponse, err error) {
  38. opts = append(r.Options[:], opts...)
  39. path := "config/providers"
  40. err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
  41. return
  42. }
  43. type Config struct {
  44. // JSON schema reference for configuration validation
  45. Schema string `json:"$schema"`
  46. // Share newly created sessions automatically
  47. Autoshare bool `json:"autoshare"`
  48. // Automatically update to the latest version
  49. Autoupdate bool `json:"autoupdate"`
  50. // Disable providers that are loaded automatically
  51. DisabledProviders []string `json:"disabled_providers"`
  52. Experimental ConfigExperimental `json:"experimental"`
  53. // Additional instruction files or patterns to include
  54. Instructions []string `json:"instructions"`
  55. // Custom keybind configurations
  56. Keybinds Keybinds `json:"keybinds"`
  57. // Minimum log level to write to log files
  58. LogLevel LogLevel `json:"log_level"`
  59. // MCP (Model Context Protocol) server configurations
  60. Mcp map[string]ConfigMcp `json:"mcp"`
  61. Mode ConfigMode `json:"mode"`
  62. // Model to use in the format of provider/model, eg anthropic/claude-2
  63. Model string `json:"model"`
  64. // Custom provider configurations and model overrides
  65. Provider map[string]ConfigProvider `json:"provider"`
  66. // Theme name to use for the interface
  67. Theme string `json:"theme"`
  68. JSON configJSON `json:"-"`
  69. }
  70. // configJSON contains the JSON metadata for the struct [Config]
  71. type configJSON struct {
  72. Schema apijson.Field
  73. Autoshare apijson.Field
  74. Autoupdate apijson.Field
  75. DisabledProviders apijson.Field
  76. Experimental apijson.Field
  77. Instructions apijson.Field
  78. Keybinds apijson.Field
  79. LogLevel apijson.Field
  80. Mcp apijson.Field
  81. Mode apijson.Field
  82. Model apijson.Field
  83. Provider apijson.Field
  84. Theme apijson.Field
  85. raw string
  86. ExtraFields map[string]apijson.Field
  87. }
  88. func (r *Config) UnmarshalJSON(data []byte) (err error) {
  89. return apijson.UnmarshalRoot(data, r)
  90. }
  91. func (r configJSON) RawJSON() string {
  92. return r.raw
  93. }
  94. type ConfigExperimental struct {
  95. Hook ConfigExperimentalHook `json:"hook"`
  96. JSON configExperimentalJSON `json:"-"`
  97. }
  98. // configExperimentalJSON contains the JSON metadata for the struct
  99. // [ConfigExperimental]
  100. type configExperimentalJSON struct {
  101. Hook apijson.Field
  102. raw string
  103. ExtraFields map[string]apijson.Field
  104. }
  105. func (r *ConfigExperimental) UnmarshalJSON(data []byte) (err error) {
  106. return apijson.UnmarshalRoot(data, r)
  107. }
  108. func (r configExperimentalJSON) RawJSON() string {
  109. return r.raw
  110. }
  111. type ConfigExperimentalHook struct {
  112. FileEdited map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"`
  113. SessionCompleted []ConfigExperimentalHookSessionCompleted `json:"session_completed"`
  114. JSON configExperimentalHookJSON `json:"-"`
  115. }
  116. // configExperimentalHookJSON contains the JSON metadata for the struct
  117. // [ConfigExperimentalHook]
  118. type configExperimentalHookJSON struct {
  119. FileEdited apijson.Field
  120. SessionCompleted apijson.Field
  121. raw string
  122. ExtraFields map[string]apijson.Field
  123. }
  124. func (r *ConfigExperimentalHook) UnmarshalJSON(data []byte) (err error) {
  125. return apijson.UnmarshalRoot(data, r)
  126. }
  127. func (r configExperimentalHookJSON) RawJSON() string {
  128. return r.raw
  129. }
  130. type ConfigExperimentalHookFileEdited struct {
  131. Command []string `json:"command,required"`
  132. Environment map[string]string `json:"environment"`
  133. JSON configExperimentalHookFileEditedJSON `json:"-"`
  134. }
  135. // configExperimentalHookFileEditedJSON contains the JSON metadata for the struct
  136. // [ConfigExperimentalHookFileEdited]
  137. type configExperimentalHookFileEditedJSON struct {
  138. Command apijson.Field
  139. Environment apijson.Field
  140. raw string
  141. ExtraFields map[string]apijson.Field
  142. }
  143. func (r *ConfigExperimentalHookFileEdited) UnmarshalJSON(data []byte) (err error) {
  144. return apijson.UnmarshalRoot(data, r)
  145. }
  146. func (r configExperimentalHookFileEditedJSON) RawJSON() string {
  147. return r.raw
  148. }
  149. type ConfigExperimentalHookSessionCompleted struct {
  150. Command []string `json:"command,required"`
  151. Environment map[string]string `json:"environment"`
  152. JSON configExperimentalHookSessionCompletedJSON `json:"-"`
  153. }
  154. // configExperimentalHookSessionCompletedJSON contains the JSON metadata for the
  155. // struct [ConfigExperimentalHookSessionCompleted]
  156. type configExperimentalHookSessionCompletedJSON struct {
  157. Command apijson.Field
  158. Environment apijson.Field
  159. raw string
  160. ExtraFields map[string]apijson.Field
  161. }
  162. func (r *ConfigExperimentalHookSessionCompleted) UnmarshalJSON(data []byte) (err error) {
  163. return apijson.UnmarshalRoot(data, r)
  164. }
  165. func (r configExperimentalHookSessionCompletedJSON) RawJSON() string {
  166. return r.raw
  167. }
  168. type ConfigMcp struct {
  169. // Type of MCP server connection
  170. Type ConfigMcpType `json:"type,required"`
  171. // This field can have the runtime type of [[]string].
  172. Command interface{} `json:"command"`
  173. // Enable or disable the MCP server on startup
  174. Enabled bool `json:"enabled"`
  175. // This field can have the runtime type of [map[string]string].
  176. Environment interface{} `json:"environment"`
  177. // URL of the remote MCP server
  178. URL string `json:"url"`
  179. JSON configMcpJSON `json:"-"`
  180. union ConfigMcpUnion
  181. }
  182. // configMcpJSON contains the JSON metadata for the struct [ConfigMcp]
  183. type configMcpJSON struct {
  184. Type apijson.Field
  185. Command apijson.Field
  186. Enabled apijson.Field
  187. Environment apijson.Field
  188. URL apijson.Field
  189. raw string
  190. ExtraFields map[string]apijson.Field
  191. }
  192. func (r configMcpJSON) RawJSON() string {
  193. return r.raw
  194. }
  195. func (r *ConfigMcp) UnmarshalJSON(data []byte) (err error) {
  196. *r = ConfigMcp{}
  197. err = apijson.UnmarshalRoot(data, &r.union)
  198. if err != nil {
  199. return err
  200. }
  201. return apijson.Port(r.union, &r)
  202. }
  203. // AsUnion returns a [ConfigMcpUnion] interface which you can cast to the specific
  204. // types for more type safety.
  205. //
  206. // Possible runtime types of the union are [McpLocal], [McpRemote].
  207. func (r ConfigMcp) AsUnion() ConfigMcpUnion {
  208. return r.union
  209. }
  210. // Union satisfied by [McpLocal] or [McpRemote].
  211. type ConfigMcpUnion interface {
  212. implementsConfigMcp()
  213. }
  214. func init() {
  215. apijson.RegisterUnion(
  216. reflect.TypeOf((*ConfigMcpUnion)(nil)).Elem(),
  217. "type",
  218. apijson.UnionVariant{
  219. TypeFilter: gjson.JSON,
  220. Type: reflect.TypeOf(McpLocal{}),
  221. DiscriminatorValue: "local",
  222. },
  223. apijson.UnionVariant{
  224. TypeFilter: gjson.JSON,
  225. Type: reflect.TypeOf(McpRemote{}),
  226. DiscriminatorValue: "remote",
  227. },
  228. )
  229. }
  230. // Type of MCP server connection
  231. type ConfigMcpType string
  232. const (
  233. ConfigMcpTypeLocal ConfigMcpType = "local"
  234. ConfigMcpTypeRemote ConfigMcpType = "remote"
  235. )
  236. func (r ConfigMcpType) IsKnown() bool {
  237. switch r {
  238. case ConfigMcpTypeLocal, ConfigMcpTypeRemote:
  239. return true
  240. }
  241. return false
  242. }
  243. type ConfigMode struct {
  244. Build ConfigModeBuild `json:"build"`
  245. Plan ConfigModePlan `json:"plan"`
  246. ExtraFields map[string]ConfigMode `json:"-,extras"`
  247. JSON configModeJSON `json:"-"`
  248. }
  249. // configModeJSON contains the JSON metadata for the struct [ConfigMode]
  250. type configModeJSON struct {
  251. Build apijson.Field
  252. Plan apijson.Field
  253. raw string
  254. ExtraFields map[string]apijson.Field
  255. }
  256. func (r *ConfigMode) UnmarshalJSON(data []byte) (err error) {
  257. return apijson.UnmarshalRoot(data, r)
  258. }
  259. func (r configModeJSON) RawJSON() string {
  260. return r.raw
  261. }
  262. type ConfigModeBuild struct {
  263. Model string `json:"model"`
  264. Prompt string `json:"prompt"`
  265. Tools map[string]bool `json:"tools"`
  266. JSON configModeBuildJSON `json:"-"`
  267. }
  268. // configModeBuildJSON contains the JSON metadata for the struct [ConfigModeBuild]
  269. type configModeBuildJSON struct {
  270. Model apijson.Field
  271. Prompt apijson.Field
  272. Tools apijson.Field
  273. raw string
  274. ExtraFields map[string]apijson.Field
  275. }
  276. func (r *ConfigModeBuild) UnmarshalJSON(data []byte) (err error) {
  277. return apijson.UnmarshalRoot(data, r)
  278. }
  279. func (r configModeBuildJSON) RawJSON() string {
  280. return r.raw
  281. }
  282. type ConfigModePlan struct {
  283. Model string `json:"model"`
  284. Prompt string `json:"prompt"`
  285. Tools map[string]bool `json:"tools"`
  286. JSON configModePlanJSON `json:"-"`
  287. }
  288. // configModePlanJSON contains the JSON metadata for the struct [ConfigModePlan]
  289. type configModePlanJSON struct {
  290. Model apijson.Field
  291. Prompt apijson.Field
  292. Tools apijson.Field
  293. raw string
  294. ExtraFields map[string]apijson.Field
  295. }
  296. func (r *ConfigModePlan) UnmarshalJSON(data []byte) (err error) {
  297. return apijson.UnmarshalRoot(data, r)
  298. }
  299. func (r configModePlanJSON) RawJSON() string {
  300. return r.raw
  301. }
  302. type ConfigProvider struct {
  303. Models map[string]ConfigProviderModel `json:"models,required"`
  304. ID string `json:"id"`
  305. API string `json:"api"`
  306. Env []string `json:"env"`
  307. Name string `json:"name"`
  308. Npm string `json:"npm"`
  309. Options map[string]interface{} `json:"options"`
  310. JSON configProviderJSON `json:"-"`
  311. }
  312. // configProviderJSON contains the JSON metadata for the struct [ConfigProvider]
  313. type configProviderJSON struct {
  314. Models apijson.Field
  315. ID apijson.Field
  316. API apijson.Field
  317. Env apijson.Field
  318. Name apijson.Field
  319. Npm apijson.Field
  320. Options apijson.Field
  321. raw string
  322. ExtraFields map[string]apijson.Field
  323. }
  324. func (r *ConfigProvider) UnmarshalJSON(data []byte) (err error) {
  325. return apijson.UnmarshalRoot(data, r)
  326. }
  327. func (r configProviderJSON) RawJSON() string {
  328. return r.raw
  329. }
  330. type ConfigProviderModel struct {
  331. ID string `json:"id"`
  332. Attachment bool `json:"attachment"`
  333. Cost ConfigProviderModelsCost `json:"cost"`
  334. Limit ConfigProviderModelsLimit `json:"limit"`
  335. Name string `json:"name"`
  336. Options map[string]interface{} `json:"options"`
  337. Reasoning bool `json:"reasoning"`
  338. ReleaseDate string `json:"release_date"`
  339. Temperature bool `json:"temperature"`
  340. ToolCall bool `json:"tool_call"`
  341. JSON configProviderModelJSON `json:"-"`
  342. }
  343. // configProviderModelJSON contains the JSON metadata for the struct
  344. // [ConfigProviderModel]
  345. type configProviderModelJSON struct {
  346. ID apijson.Field
  347. Attachment apijson.Field
  348. Cost apijson.Field
  349. Limit apijson.Field
  350. Name apijson.Field
  351. Options apijson.Field
  352. Reasoning apijson.Field
  353. ReleaseDate apijson.Field
  354. Temperature apijson.Field
  355. ToolCall apijson.Field
  356. raw string
  357. ExtraFields map[string]apijson.Field
  358. }
  359. func (r *ConfigProviderModel) UnmarshalJSON(data []byte) (err error) {
  360. return apijson.UnmarshalRoot(data, r)
  361. }
  362. func (r configProviderModelJSON) RawJSON() string {
  363. return r.raw
  364. }
  365. type ConfigProviderModelsCost struct {
  366. Input float64 `json:"input,required"`
  367. Output float64 `json:"output,required"`
  368. CacheRead float64 `json:"cache_read"`
  369. CacheWrite float64 `json:"cache_write"`
  370. JSON configProviderModelsCostJSON `json:"-"`
  371. }
  372. // configProviderModelsCostJSON contains the JSON metadata for the struct
  373. // [ConfigProviderModelsCost]
  374. type configProviderModelsCostJSON struct {
  375. Input apijson.Field
  376. Output apijson.Field
  377. CacheRead apijson.Field
  378. CacheWrite apijson.Field
  379. raw string
  380. ExtraFields map[string]apijson.Field
  381. }
  382. func (r *ConfigProviderModelsCost) UnmarshalJSON(data []byte) (err error) {
  383. return apijson.UnmarshalRoot(data, r)
  384. }
  385. func (r configProviderModelsCostJSON) RawJSON() string {
  386. return r.raw
  387. }
  388. type ConfigProviderModelsLimit struct {
  389. Context float64 `json:"context,required"`
  390. Output float64 `json:"output,required"`
  391. JSON configProviderModelsLimitJSON `json:"-"`
  392. }
  393. // configProviderModelsLimitJSON contains the JSON metadata for the struct
  394. // [ConfigProviderModelsLimit]
  395. type configProviderModelsLimitJSON struct {
  396. Context apijson.Field
  397. Output apijson.Field
  398. raw string
  399. ExtraFields map[string]apijson.Field
  400. }
  401. func (r *ConfigProviderModelsLimit) UnmarshalJSON(data []byte) (err error) {
  402. return apijson.UnmarshalRoot(data, r)
  403. }
  404. func (r configProviderModelsLimitJSON) RawJSON() string {
  405. return r.raw
  406. }
  407. type Keybinds struct {
  408. // Exit the application
  409. AppExit string `json:"app_exit,required"`
  410. // Show help dialog
  411. AppHelp string `json:"app_help,required"`
  412. // Open external editor
  413. EditorOpen string `json:"editor_open,required"`
  414. // Close file
  415. FileClose string `json:"file_close,required"`
  416. // Split/unified diff
  417. FileDiffToggle string `json:"file_diff_toggle,required"`
  418. // List files
  419. FileList string `json:"file_list,required"`
  420. // Search file
  421. FileSearch string `json:"file_search,required"`
  422. // Clear input field
  423. InputClear string `json:"input_clear,required"`
  424. // Insert newline in input
  425. InputNewline string `json:"input_newline,required"`
  426. // Paste from clipboard
  427. InputPaste string `json:"input_paste,required"`
  428. // Submit input
  429. InputSubmit string `json:"input_submit,required"`
  430. // Leader key for keybind combinations
  431. Leader string `json:"leader,required"`
  432. // Copy message
  433. MessagesCopy string `json:"messages_copy,required"`
  434. // Navigate to first message
  435. MessagesFirst string `json:"messages_first,required"`
  436. // Scroll messages down by half page
  437. MessagesHalfPageDown string `json:"messages_half_page_down,required"`
  438. // Scroll messages up by half page
  439. MessagesHalfPageUp string `json:"messages_half_page_up,required"`
  440. // Navigate to last message
  441. MessagesLast string `json:"messages_last,required"`
  442. // Toggle layout
  443. MessagesLayoutToggle string `json:"messages_layout_toggle,required"`
  444. // Navigate to next message
  445. MessagesNext string `json:"messages_next,required"`
  446. // Scroll messages down by one page
  447. MessagesPageDown string `json:"messages_page_down,required"`
  448. // Scroll messages up by one page
  449. MessagesPageUp string `json:"messages_page_up,required"`
  450. // Navigate to previous message
  451. MessagesPrevious string `json:"messages_previous,required"`
  452. // Revert message
  453. MessagesRevert string `json:"messages_revert,required"`
  454. // List available models
  455. ModelList string `json:"model_list,required"`
  456. // Create/update AGENTS.md
  457. ProjectInit string `json:"project_init,required"`
  458. // Compact the session
  459. SessionCompact string `json:"session_compact,required"`
  460. // Interrupt current session
  461. SessionInterrupt string `json:"session_interrupt,required"`
  462. // List all sessions
  463. SessionList string `json:"session_list,required"`
  464. // Create a new session
  465. SessionNew string `json:"session_new,required"`
  466. // Share current session
  467. SessionShare string `json:"session_share,required"`
  468. // Unshare current session
  469. SessionUnshare string `json:"session_unshare,required"`
  470. // Switch mode
  471. SwitchMode string `json:"switch_mode,required"`
  472. // List available themes
  473. ThemeList string `json:"theme_list,required"`
  474. // Toggle tool details
  475. ToolDetails string `json:"tool_details,required"`
  476. JSON keybindsJSON `json:"-"`
  477. }
  478. // keybindsJSON contains the JSON metadata for the struct [Keybinds]
  479. type keybindsJSON struct {
  480. AppExit apijson.Field
  481. AppHelp apijson.Field
  482. EditorOpen apijson.Field
  483. FileClose apijson.Field
  484. FileDiffToggle apijson.Field
  485. FileList apijson.Field
  486. FileSearch apijson.Field
  487. InputClear apijson.Field
  488. InputNewline apijson.Field
  489. InputPaste apijson.Field
  490. InputSubmit apijson.Field
  491. Leader apijson.Field
  492. MessagesCopy apijson.Field
  493. MessagesFirst apijson.Field
  494. MessagesHalfPageDown apijson.Field
  495. MessagesHalfPageUp apijson.Field
  496. MessagesLast apijson.Field
  497. MessagesLayoutToggle apijson.Field
  498. MessagesNext apijson.Field
  499. MessagesPageDown apijson.Field
  500. MessagesPageUp apijson.Field
  501. MessagesPrevious apijson.Field
  502. MessagesRevert apijson.Field
  503. ModelList apijson.Field
  504. ProjectInit apijson.Field
  505. SessionCompact apijson.Field
  506. SessionInterrupt apijson.Field
  507. SessionList apijson.Field
  508. SessionNew apijson.Field
  509. SessionShare apijson.Field
  510. SessionUnshare apijson.Field
  511. SwitchMode apijson.Field
  512. ThemeList apijson.Field
  513. ToolDetails apijson.Field
  514. raw string
  515. ExtraFields map[string]apijson.Field
  516. }
  517. func (r *Keybinds) UnmarshalJSON(data []byte) (err error) {
  518. return apijson.UnmarshalRoot(data, r)
  519. }
  520. func (r keybindsJSON) RawJSON() string {
  521. return r.raw
  522. }
  523. type McpLocal struct {
  524. // Command and arguments to run the MCP server
  525. Command []string `json:"command,required"`
  526. // Type of MCP server connection
  527. Type McpLocalType `json:"type,required"`
  528. // Enable or disable the MCP server on startup
  529. Enabled bool `json:"enabled"`
  530. // Environment variables to set when running the MCP server
  531. Environment map[string]string `json:"environment"`
  532. JSON mcpLocalJSON `json:"-"`
  533. }
  534. // mcpLocalJSON contains the JSON metadata for the struct [McpLocal]
  535. type mcpLocalJSON struct {
  536. Command apijson.Field
  537. Type apijson.Field
  538. Enabled apijson.Field
  539. Environment apijson.Field
  540. raw string
  541. ExtraFields map[string]apijson.Field
  542. }
  543. func (r *McpLocal) UnmarshalJSON(data []byte) (err error) {
  544. return apijson.UnmarshalRoot(data, r)
  545. }
  546. func (r mcpLocalJSON) RawJSON() string {
  547. return r.raw
  548. }
  549. func (r McpLocal) implementsConfigMcp() {}
  550. // Type of MCP server connection
  551. type McpLocalType string
  552. const (
  553. McpLocalTypeLocal McpLocalType = "local"
  554. )
  555. func (r McpLocalType) IsKnown() bool {
  556. switch r {
  557. case McpLocalTypeLocal:
  558. return true
  559. }
  560. return false
  561. }
  562. type McpRemote struct {
  563. // Type of MCP server connection
  564. Type McpRemoteType `json:"type,required"`
  565. // URL of the remote MCP server
  566. URL string `json:"url,required"`
  567. // Enable or disable the MCP server on startup
  568. Enabled bool `json:"enabled"`
  569. JSON mcpRemoteJSON `json:"-"`
  570. }
  571. // mcpRemoteJSON contains the JSON metadata for the struct [McpRemote]
  572. type mcpRemoteJSON struct {
  573. Type apijson.Field
  574. URL apijson.Field
  575. Enabled apijson.Field
  576. raw string
  577. ExtraFields map[string]apijson.Field
  578. }
  579. func (r *McpRemote) UnmarshalJSON(data []byte) (err error) {
  580. return apijson.UnmarshalRoot(data, r)
  581. }
  582. func (r mcpRemoteJSON) RawJSON() string {
  583. return r.raw
  584. }
  585. func (r McpRemote) implementsConfigMcp() {}
  586. // Type of MCP server connection
  587. type McpRemoteType string
  588. const (
  589. McpRemoteTypeRemote McpRemoteType = "remote"
  590. )
  591. func (r McpRemoteType) IsKnown() bool {
  592. switch r {
  593. case McpRemoteTypeRemote:
  594. return true
  595. }
  596. return false
  597. }
  598. type Model struct {
  599. ID string `json:"id,required"`
  600. Attachment bool `json:"attachment,required"`
  601. Cost ModelCost `json:"cost,required"`
  602. Limit ModelLimit `json:"limit,required"`
  603. Name string `json:"name,required"`
  604. Options map[string]interface{} `json:"options,required"`
  605. Reasoning bool `json:"reasoning,required"`
  606. ReleaseDate string `json:"release_date,required"`
  607. Temperature bool `json:"temperature,required"`
  608. ToolCall bool `json:"tool_call,required"`
  609. JSON modelJSON `json:"-"`
  610. }
  611. // modelJSON contains the JSON metadata for the struct [Model]
  612. type modelJSON struct {
  613. ID apijson.Field
  614. Attachment apijson.Field
  615. Cost apijson.Field
  616. Limit apijson.Field
  617. Name apijson.Field
  618. Options apijson.Field
  619. Reasoning apijson.Field
  620. ReleaseDate apijson.Field
  621. Temperature apijson.Field
  622. ToolCall apijson.Field
  623. raw string
  624. ExtraFields map[string]apijson.Field
  625. }
  626. func (r *Model) UnmarshalJSON(data []byte) (err error) {
  627. return apijson.UnmarshalRoot(data, r)
  628. }
  629. func (r modelJSON) RawJSON() string {
  630. return r.raw
  631. }
  632. type ModelCost struct {
  633. Input float64 `json:"input,required"`
  634. Output float64 `json:"output,required"`
  635. CacheRead float64 `json:"cache_read"`
  636. CacheWrite float64 `json:"cache_write"`
  637. JSON modelCostJSON `json:"-"`
  638. }
  639. // modelCostJSON contains the JSON metadata for the struct [ModelCost]
  640. type modelCostJSON struct {
  641. Input apijson.Field
  642. Output apijson.Field
  643. CacheRead apijson.Field
  644. CacheWrite apijson.Field
  645. raw string
  646. ExtraFields map[string]apijson.Field
  647. }
  648. func (r *ModelCost) UnmarshalJSON(data []byte) (err error) {
  649. return apijson.UnmarshalRoot(data, r)
  650. }
  651. func (r modelCostJSON) RawJSON() string {
  652. return r.raw
  653. }
  654. type ModelLimit struct {
  655. Context float64 `json:"context,required"`
  656. Output float64 `json:"output,required"`
  657. JSON modelLimitJSON `json:"-"`
  658. }
  659. // modelLimitJSON contains the JSON metadata for the struct [ModelLimit]
  660. type modelLimitJSON struct {
  661. Context apijson.Field
  662. Output apijson.Field
  663. raw string
  664. ExtraFields map[string]apijson.Field
  665. }
  666. func (r *ModelLimit) UnmarshalJSON(data []byte) (err error) {
  667. return apijson.UnmarshalRoot(data, r)
  668. }
  669. func (r modelLimitJSON) RawJSON() string {
  670. return r.raw
  671. }
  672. type Provider struct {
  673. ID string `json:"id,required"`
  674. Env []string `json:"env,required"`
  675. Models map[string]Model `json:"models,required"`
  676. Name string `json:"name,required"`
  677. API string `json:"api"`
  678. Npm string `json:"npm"`
  679. JSON providerJSON `json:"-"`
  680. }
  681. // providerJSON contains the JSON metadata for the struct [Provider]
  682. type providerJSON struct {
  683. ID apijson.Field
  684. Env apijson.Field
  685. Models apijson.Field
  686. Name apijson.Field
  687. API apijson.Field
  688. Npm apijson.Field
  689. raw string
  690. ExtraFields map[string]apijson.Field
  691. }
  692. func (r *Provider) UnmarshalJSON(data []byte) (err error) {
  693. return apijson.UnmarshalRoot(data, r)
  694. }
  695. func (r providerJSON) RawJSON() string {
  696. return r.raw
  697. }
  698. type ConfigProvidersResponse struct {
  699. Default map[string]string `json:"default,required"`
  700. Providers []Provider `json:"providers,required"`
  701. JSON configProvidersResponseJSON `json:"-"`
  702. }
  703. // configProvidersResponseJSON contains the JSON metadata for the struct
  704. // [ConfigProvidersResponse]
  705. type configProvidersResponseJSON struct {
  706. Default apijson.Field
  707. Providers apijson.Field
  708. raw string
  709. ExtraFields map[string]apijson.Field
  710. }
  711. func (r *ConfigProvidersResponse) UnmarshalJSON(data []byte) (err error) {
  712. return apijson.UnmarshalRoot(data, r)
  713. }
  714. func (r configProvidersResponseJSON) RawJSON() string {
  715. return r.raw
  716. }