config.go 22 KB

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