2
0

config.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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. type Config struct {
  37. // JSON schema reference for configuration validation
  38. Schema string `json:"$schema"`
  39. // @deprecated Use 'share' field instead. Share newly created sessions
  40. // automatically
  41. Autoshare bool `json:"autoshare"`
  42. // Automatically update to the latest version
  43. Autoupdate bool `json:"autoupdate"`
  44. // Disable providers that are loaded automatically
  45. DisabledProviders []string `json:"disabled_providers"`
  46. Experimental ConfigExperimental `json:"experimental"`
  47. // Additional instruction files or patterns to include
  48. Instructions []string `json:"instructions"`
  49. // Custom keybind configurations
  50. Keybinds KeybindsConfig `json:"keybinds"`
  51. // Layout to use for the TUI
  52. Layout LayoutConfig `json:"layout"`
  53. // Minimum log level to write to log files
  54. LogLevel LogLevel `json:"log_level"`
  55. // MCP (Model Context Protocol) server configurations
  56. Mcp map[string]ConfigMcp `json:"mcp"`
  57. // Modes configuration, see https://opencode.ai/docs/modes
  58. Mode ConfigMode `json:"mode"`
  59. // Model to use in the format of provider/model, eg anthropic/claude-2
  60. Model string `json:"model"`
  61. // Custom provider configurations and model overrides
  62. Provider map[string]ConfigProvider `json:"provider"`
  63. // Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
  64. // all sharing
  65. Share ConfigShare `json:"share"`
  66. // Theme name to use for the interface
  67. Theme string `json:"theme"`
  68. // Custom username to display in conversations instead of system username
  69. Username string `json:"username"`
  70. JSON configJSON `json:"-"`
  71. }
  72. // configJSON contains the JSON metadata for the struct [Config]
  73. type configJSON struct {
  74. Schema apijson.Field
  75. Autoshare apijson.Field
  76. Autoupdate apijson.Field
  77. DisabledProviders apijson.Field
  78. Experimental apijson.Field
  79. Instructions apijson.Field
  80. Keybinds apijson.Field
  81. Layout apijson.Field
  82. LogLevel apijson.Field
  83. Mcp apijson.Field
  84. Mode apijson.Field
  85. Model apijson.Field
  86. Provider apijson.Field
  87. Share apijson.Field
  88. Theme apijson.Field
  89. Username apijson.Field
  90. raw string
  91. ExtraFields map[string]apijson.Field
  92. }
  93. func (r *Config) UnmarshalJSON(data []byte) (err error) {
  94. return apijson.UnmarshalRoot(data, r)
  95. }
  96. func (r configJSON) RawJSON() string {
  97. return r.raw
  98. }
  99. type ConfigExperimental struct {
  100. Hook ConfigExperimentalHook `json:"hook"`
  101. JSON configExperimentalJSON `json:"-"`
  102. }
  103. // configExperimentalJSON contains the JSON metadata for the struct
  104. // [ConfigExperimental]
  105. type configExperimentalJSON struct {
  106. Hook apijson.Field
  107. raw string
  108. ExtraFields map[string]apijson.Field
  109. }
  110. func (r *ConfigExperimental) UnmarshalJSON(data []byte) (err error) {
  111. return apijson.UnmarshalRoot(data, r)
  112. }
  113. func (r configExperimentalJSON) RawJSON() string {
  114. return r.raw
  115. }
  116. type ConfigExperimentalHook struct {
  117. FileEdited map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"`
  118. SessionCompleted []ConfigExperimentalHookSessionCompleted `json:"session_completed"`
  119. JSON configExperimentalHookJSON `json:"-"`
  120. }
  121. // configExperimentalHookJSON contains the JSON metadata for the struct
  122. // [ConfigExperimentalHook]
  123. type configExperimentalHookJSON struct {
  124. FileEdited apijson.Field
  125. SessionCompleted apijson.Field
  126. raw string
  127. ExtraFields map[string]apijson.Field
  128. }
  129. func (r *ConfigExperimentalHook) UnmarshalJSON(data []byte) (err error) {
  130. return apijson.UnmarshalRoot(data, r)
  131. }
  132. func (r configExperimentalHookJSON) RawJSON() string {
  133. return r.raw
  134. }
  135. type ConfigExperimentalHookFileEdited struct {
  136. Command []string `json:"command,required"`
  137. Environment map[string]string `json:"environment"`
  138. JSON configExperimentalHookFileEditedJSON `json:"-"`
  139. }
  140. // configExperimentalHookFileEditedJSON contains the JSON metadata for the struct
  141. // [ConfigExperimentalHookFileEdited]
  142. type configExperimentalHookFileEditedJSON struct {
  143. Command apijson.Field
  144. Environment apijson.Field
  145. raw string
  146. ExtraFields map[string]apijson.Field
  147. }
  148. func (r *ConfigExperimentalHookFileEdited) UnmarshalJSON(data []byte) (err error) {
  149. return apijson.UnmarshalRoot(data, r)
  150. }
  151. func (r configExperimentalHookFileEditedJSON) RawJSON() string {
  152. return r.raw
  153. }
  154. type ConfigExperimentalHookSessionCompleted struct {
  155. Command []string `json:"command,required"`
  156. Environment map[string]string `json:"environment"`
  157. JSON configExperimentalHookSessionCompletedJSON `json:"-"`
  158. }
  159. // configExperimentalHookSessionCompletedJSON contains the JSON metadata for the
  160. // struct [ConfigExperimentalHookSessionCompleted]
  161. type configExperimentalHookSessionCompletedJSON struct {
  162. Command apijson.Field
  163. Environment apijson.Field
  164. raw string
  165. ExtraFields map[string]apijson.Field
  166. }
  167. func (r *ConfigExperimentalHookSessionCompleted) UnmarshalJSON(data []byte) (err error) {
  168. return apijson.UnmarshalRoot(data, r)
  169. }
  170. func (r configExperimentalHookSessionCompletedJSON) RawJSON() string {
  171. return r.raw
  172. }
  173. type ConfigMcp struct {
  174. // Type of MCP server connection
  175. Type ConfigMcpType `json:"type,required"`
  176. // This field can have the runtime type of [[]string].
  177. Command interface{} `json:"command"`
  178. // Enable or disable the MCP server on startup
  179. Enabled bool `json:"enabled"`
  180. // This field can have the runtime type of [map[string]string].
  181. Environment interface{} `json:"environment"`
  182. // URL of the remote MCP server
  183. URL string `json:"url"`
  184. JSON configMcpJSON `json:"-"`
  185. union ConfigMcpUnion
  186. }
  187. // configMcpJSON contains the JSON metadata for the struct [ConfigMcp]
  188. type configMcpJSON struct {
  189. Type apijson.Field
  190. Command apijson.Field
  191. Enabled apijson.Field
  192. Environment apijson.Field
  193. URL apijson.Field
  194. raw string
  195. ExtraFields map[string]apijson.Field
  196. }
  197. func (r configMcpJSON) RawJSON() string {
  198. return r.raw
  199. }
  200. func (r *ConfigMcp) UnmarshalJSON(data []byte) (err error) {
  201. *r = ConfigMcp{}
  202. err = apijson.UnmarshalRoot(data, &r.union)
  203. if err != nil {
  204. return err
  205. }
  206. return apijson.Port(r.union, &r)
  207. }
  208. // AsUnion returns a [ConfigMcpUnion] interface which you can cast to the specific
  209. // types for more type safety.
  210. //
  211. // Possible runtime types of the union are [McpLocalConfig], [McpRemoteConfig].
  212. func (r ConfigMcp) AsUnion() ConfigMcpUnion {
  213. return r.union
  214. }
  215. // Union satisfied by [McpLocalConfig] or [McpRemoteConfig].
  216. type ConfigMcpUnion interface {
  217. implementsConfigMcp()
  218. }
  219. func init() {
  220. apijson.RegisterUnion(
  221. reflect.TypeOf((*ConfigMcpUnion)(nil)).Elem(),
  222. "type",
  223. apijson.UnionVariant{
  224. TypeFilter: gjson.JSON,
  225. Type: reflect.TypeOf(McpLocalConfig{}),
  226. DiscriminatorValue: "local",
  227. },
  228. apijson.UnionVariant{
  229. TypeFilter: gjson.JSON,
  230. Type: reflect.TypeOf(McpRemoteConfig{}),
  231. DiscriminatorValue: "remote",
  232. },
  233. )
  234. }
  235. // Type of MCP server connection
  236. type ConfigMcpType string
  237. const (
  238. ConfigMcpTypeLocal ConfigMcpType = "local"
  239. ConfigMcpTypeRemote ConfigMcpType = "remote"
  240. )
  241. func (r ConfigMcpType) IsKnown() bool {
  242. switch r {
  243. case ConfigMcpTypeLocal, ConfigMcpTypeRemote:
  244. return true
  245. }
  246. return false
  247. }
  248. // Modes configuration, see https://opencode.ai/docs/modes
  249. type ConfigMode struct {
  250. Build ModeConfig `json:"build"`
  251. Plan ModeConfig `json:"plan"`
  252. ExtraFields map[string]ModeConfig `json:"-,extras"`
  253. JSON configModeJSON `json:"-"`
  254. }
  255. // configModeJSON contains the JSON metadata for the struct [ConfigMode]
  256. type configModeJSON struct {
  257. Build apijson.Field
  258. Plan apijson.Field
  259. raw string
  260. ExtraFields map[string]apijson.Field
  261. }
  262. func (r *ConfigMode) UnmarshalJSON(data []byte) (err error) {
  263. return apijson.UnmarshalRoot(data, r)
  264. }
  265. func (r configModeJSON) RawJSON() string {
  266. return r.raw
  267. }
  268. type ConfigProvider struct {
  269. Models map[string]ConfigProviderModel `json:"models,required"`
  270. ID string `json:"id"`
  271. API string `json:"api"`
  272. Env []string `json:"env"`
  273. Name string `json:"name"`
  274. Npm string `json:"npm"`
  275. Options map[string]interface{} `json:"options"`
  276. JSON configProviderJSON `json:"-"`
  277. }
  278. // configProviderJSON contains the JSON metadata for the struct [ConfigProvider]
  279. type configProviderJSON struct {
  280. Models apijson.Field
  281. ID apijson.Field
  282. API apijson.Field
  283. Env apijson.Field
  284. Name apijson.Field
  285. Npm apijson.Field
  286. Options apijson.Field
  287. raw string
  288. ExtraFields map[string]apijson.Field
  289. }
  290. func (r *ConfigProvider) UnmarshalJSON(data []byte) (err error) {
  291. return apijson.UnmarshalRoot(data, r)
  292. }
  293. func (r configProviderJSON) RawJSON() string {
  294. return r.raw
  295. }
  296. type ConfigProviderModel struct {
  297. ID string `json:"id"`
  298. Attachment bool `json:"attachment"`
  299. Cost ConfigProviderModelsCost `json:"cost"`
  300. Limit ConfigProviderModelsLimit `json:"limit"`
  301. Name string `json:"name"`
  302. Options map[string]interface{} `json:"options"`
  303. Reasoning bool `json:"reasoning"`
  304. ReleaseDate string `json:"release_date"`
  305. Temperature bool `json:"temperature"`
  306. ToolCall bool `json:"tool_call"`
  307. JSON configProviderModelJSON `json:"-"`
  308. }
  309. // configProviderModelJSON contains the JSON metadata for the struct
  310. // [ConfigProviderModel]
  311. type configProviderModelJSON struct {
  312. ID apijson.Field
  313. Attachment apijson.Field
  314. Cost apijson.Field
  315. Limit apijson.Field
  316. Name apijson.Field
  317. Options apijson.Field
  318. Reasoning apijson.Field
  319. ReleaseDate apijson.Field
  320. Temperature apijson.Field
  321. ToolCall apijson.Field
  322. raw string
  323. ExtraFields map[string]apijson.Field
  324. }
  325. func (r *ConfigProviderModel) UnmarshalJSON(data []byte) (err error) {
  326. return apijson.UnmarshalRoot(data, r)
  327. }
  328. func (r configProviderModelJSON) RawJSON() string {
  329. return r.raw
  330. }
  331. type ConfigProviderModelsCost struct {
  332. Input float64 `json:"input,required"`
  333. Output float64 `json:"output,required"`
  334. CacheRead float64 `json:"cache_read"`
  335. CacheWrite float64 `json:"cache_write"`
  336. JSON configProviderModelsCostJSON `json:"-"`
  337. }
  338. // configProviderModelsCostJSON contains the JSON metadata for the struct
  339. // [ConfigProviderModelsCost]
  340. type configProviderModelsCostJSON struct {
  341. Input apijson.Field
  342. Output apijson.Field
  343. CacheRead apijson.Field
  344. CacheWrite apijson.Field
  345. raw string
  346. ExtraFields map[string]apijson.Field
  347. }
  348. func (r *ConfigProviderModelsCost) UnmarshalJSON(data []byte) (err error) {
  349. return apijson.UnmarshalRoot(data, r)
  350. }
  351. func (r configProviderModelsCostJSON) RawJSON() string {
  352. return r.raw
  353. }
  354. type ConfigProviderModelsLimit struct {
  355. Context float64 `json:"context,required"`
  356. Output float64 `json:"output,required"`
  357. JSON configProviderModelsLimitJSON `json:"-"`
  358. }
  359. // configProviderModelsLimitJSON contains the JSON metadata for the struct
  360. // [ConfigProviderModelsLimit]
  361. type configProviderModelsLimitJSON struct {
  362. Context apijson.Field
  363. Output apijson.Field
  364. raw string
  365. ExtraFields map[string]apijson.Field
  366. }
  367. func (r *ConfigProviderModelsLimit) UnmarshalJSON(data []byte) (err error) {
  368. return apijson.UnmarshalRoot(data, r)
  369. }
  370. func (r configProviderModelsLimitJSON) RawJSON() string {
  371. return r.raw
  372. }
  373. // Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
  374. // all sharing
  375. type ConfigShare string
  376. const (
  377. ConfigShareAuto ConfigShare = "auto"
  378. ConfigShareDisabled ConfigShare = "disabled"
  379. )
  380. func (r ConfigShare) IsKnown() bool {
  381. switch r {
  382. case ConfigShareAuto, ConfigShareDisabled:
  383. return true
  384. }
  385. return false
  386. }
  387. type KeybindsConfig struct {
  388. // Exit the application
  389. AppExit string `json:"app_exit,required"`
  390. // Show help dialog
  391. AppHelp string `json:"app_help,required"`
  392. // Open external editor
  393. EditorOpen string `json:"editor_open,required"`
  394. // Close file
  395. FileClose string `json:"file_close,required"`
  396. // Split/unified diff
  397. FileDiffToggle string `json:"file_diff_toggle,required"`
  398. // List files
  399. FileList string `json:"file_list,required"`
  400. // Search file
  401. FileSearch string `json:"file_search,required"`
  402. // Clear input field
  403. InputClear string `json:"input_clear,required"`
  404. // Insert newline in input
  405. InputNewline string `json:"input_newline,required"`
  406. // Paste from clipboard
  407. InputPaste string `json:"input_paste,required"`
  408. // Submit input
  409. InputSubmit string `json:"input_submit,required"`
  410. // Leader key for keybind combinations
  411. Leader string `json:"leader,required"`
  412. // Copy message
  413. MessagesCopy string `json:"messages_copy,required"`
  414. // Navigate to first message
  415. MessagesFirst string `json:"messages_first,required"`
  416. // Scroll messages down by half page
  417. MessagesHalfPageDown string `json:"messages_half_page_down,required"`
  418. // Scroll messages up by half page
  419. MessagesHalfPageUp string `json:"messages_half_page_up,required"`
  420. // Navigate to last message
  421. MessagesLast string `json:"messages_last,required"`
  422. // Toggle layout
  423. MessagesLayoutToggle string `json:"messages_layout_toggle,required"`
  424. // Navigate to next message
  425. MessagesNext string `json:"messages_next,required"`
  426. // Scroll messages down by one page
  427. MessagesPageDown string `json:"messages_page_down,required"`
  428. // Scroll messages up by one page
  429. MessagesPageUp string `json:"messages_page_up,required"`
  430. // Navigate to previous message
  431. MessagesPrevious string `json:"messages_previous,required"`
  432. // Revert message
  433. MessagesRevert string `json:"messages_revert,required"`
  434. // List available models
  435. ModelList string `json:"model_list,required"`
  436. // Create/update AGENTS.md
  437. ProjectInit string `json:"project_init,required"`
  438. // Compact the session
  439. SessionCompact string `json:"session_compact,required"`
  440. // Export session to editor
  441. SessionExport string `json:"session_export,required"`
  442. // Interrupt current session
  443. SessionInterrupt string `json:"session_interrupt,required"`
  444. // List all sessions
  445. SessionList string `json:"session_list,required"`
  446. // Create a new session
  447. SessionNew string `json:"session_new,required"`
  448. // Share current session
  449. SessionShare string `json:"session_share,required"`
  450. // Unshare current session
  451. SessionUnshare string `json:"session_unshare,required"`
  452. // Switch mode
  453. SwitchMode string `json:"switch_mode,required"`
  454. // Switch mode reverse
  455. SwitchModeReverse string `json:"switch_mode_reverse,required"`
  456. // List available themes
  457. ThemeList string `json:"theme_list,required"`
  458. // Toggle tool details
  459. ToolDetails string `json:"tool_details,required"`
  460. JSON keybindsConfigJSON `json:"-"`
  461. }
  462. // keybindsConfigJSON contains the JSON metadata for the struct [KeybindsConfig]
  463. type keybindsConfigJSON struct {
  464. AppExit apijson.Field
  465. AppHelp apijson.Field
  466. EditorOpen apijson.Field
  467. FileClose apijson.Field
  468. FileDiffToggle apijson.Field
  469. FileList apijson.Field
  470. FileSearch apijson.Field
  471. InputClear apijson.Field
  472. InputNewline apijson.Field
  473. InputPaste apijson.Field
  474. InputSubmit apijson.Field
  475. Leader apijson.Field
  476. MessagesCopy apijson.Field
  477. MessagesFirst apijson.Field
  478. MessagesHalfPageDown apijson.Field
  479. MessagesHalfPageUp apijson.Field
  480. MessagesLast apijson.Field
  481. MessagesLayoutToggle apijson.Field
  482. MessagesNext apijson.Field
  483. MessagesPageDown apijson.Field
  484. MessagesPageUp apijson.Field
  485. MessagesPrevious apijson.Field
  486. MessagesRevert apijson.Field
  487. ModelList apijson.Field
  488. ProjectInit apijson.Field
  489. SessionCompact apijson.Field
  490. SessionExport apijson.Field
  491. SessionInterrupt apijson.Field
  492. SessionList apijson.Field
  493. SessionNew apijson.Field
  494. SessionShare apijson.Field
  495. SessionUnshare apijson.Field
  496. SwitchMode apijson.Field
  497. SwitchModeReverse apijson.Field
  498. ThemeList apijson.Field
  499. ToolDetails apijson.Field
  500. raw string
  501. ExtraFields map[string]apijson.Field
  502. }
  503. func (r *KeybindsConfig) UnmarshalJSON(data []byte) (err error) {
  504. return apijson.UnmarshalRoot(data, r)
  505. }
  506. func (r keybindsConfigJSON) RawJSON() string {
  507. return r.raw
  508. }
  509. type LayoutConfig string
  510. const (
  511. LayoutConfigAuto LayoutConfig = "auto"
  512. LayoutConfigStretch LayoutConfig = "stretch"
  513. )
  514. func (r LayoutConfig) IsKnown() bool {
  515. switch r {
  516. case LayoutConfigAuto, LayoutConfigStretch:
  517. return true
  518. }
  519. return false
  520. }
  521. type McpLocalConfig struct {
  522. // Command and arguments to run the MCP server
  523. Command []string `json:"command,required"`
  524. // Type of MCP server connection
  525. Type McpLocalConfigType `json:"type,required"`
  526. // Enable or disable the MCP server on startup
  527. Enabled bool `json:"enabled"`
  528. // Environment variables to set when running the MCP server
  529. Environment map[string]string `json:"environment"`
  530. JSON mcpLocalConfigJSON `json:"-"`
  531. }
  532. // mcpLocalConfigJSON contains the JSON metadata for the struct [McpLocalConfig]
  533. type mcpLocalConfigJSON struct {
  534. Command apijson.Field
  535. Type apijson.Field
  536. Enabled apijson.Field
  537. Environment apijson.Field
  538. raw string
  539. ExtraFields map[string]apijson.Field
  540. }
  541. func (r *McpLocalConfig) UnmarshalJSON(data []byte) (err error) {
  542. return apijson.UnmarshalRoot(data, r)
  543. }
  544. func (r mcpLocalConfigJSON) RawJSON() string {
  545. return r.raw
  546. }
  547. func (r McpLocalConfig) implementsConfigMcp() {}
  548. // Type of MCP server connection
  549. type McpLocalConfigType string
  550. const (
  551. McpLocalConfigTypeLocal McpLocalConfigType = "local"
  552. )
  553. func (r McpLocalConfigType) IsKnown() bool {
  554. switch r {
  555. case McpLocalConfigTypeLocal:
  556. return true
  557. }
  558. return false
  559. }
  560. type McpRemoteConfig struct {
  561. // Type of MCP server connection
  562. Type McpRemoteConfigType `json:"type,required"`
  563. // URL of the remote MCP server
  564. URL string `json:"url,required"`
  565. // Enable or disable the MCP server on startup
  566. Enabled bool `json:"enabled"`
  567. JSON mcpRemoteConfigJSON `json:"-"`
  568. }
  569. // mcpRemoteConfigJSON contains the JSON metadata for the struct [McpRemoteConfig]
  570. type mcpRemoteConfigJSON struct {
  571. Type apijson.Field
  572. URL apijson.Field
  573. Enabled apijson.Field
  574. raw string
  575. ExtraFields map[string]apijson.Field
  576. }
  577. func (r *McpRemoteConfig) UnmarshalJSON(data []byte) (err error) {
  578. return apijson.UnmarshalRoot(data, r)
  579. }
  580. func (r mcpRemoteConfigJSON) RawJSON() string {
  581. return r.raw
  582. }
  583. func (r McpRemoteConfig) implementsConfigMcp() {}
  584. // Type of MCP server connection
  585. type McpRemoteConfigType string
  586. const (
  587. McpRemoteConfigTypeRemote McpRemoteConfigType = "remote"
  588. )
  589. func (r McpRemoteConfigType) IsKnown() bool {
  590. switch r {
  591. case McpRemoteConfigTypeRemote:
  592. return true
  593. }
  594. return false
  595. }
  596. type ModeConfig struct {
  597. Model string `json:"model"`
  598. Prompt string `json:"prompt"`
  599. Tools map[string]bool `json:"tools"`
  600. JSON modeConfigJSON `json:"-"`
  601. }
  602. // modeConfigJSON contains the JSON metadata for the struct [ModeConfig]
  603. type modeConfigJSON struct {
  604. Model apijson.Field
  605. Prompt apijson.Field
  606. Tools apijson.Field
  607. raw string
  608. ExtraFields map[string]apijson.Field
  609. }
  610. func (r *ModeConfig) UnmarshalJSON(data []byte) (err error) {
  611. return apijson.UnmarshalRoot(data, r)
  612. }
  613. func (r modeConfigJSON) RawJSON() string {
  614. return r.raw
  615. }