config.go 21 KB

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