@opencode-ai/sdk 0.1.0-alpha.2 → 0.1.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/LICENSE +198 -4
  3. package/README.md +27 -9
  4. package/client.d.mts +25 -53
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +25 -53
  7. package/client.d.ts.map +1 -1
  8. package/client.js +25 -55
  9. package/client.js.map +1 -1
  10. package/client.mjs +25 -55
  11. package/client.mjs.map +1 -1
  12. package/core/streaming.d.mts +33 -0
  13. package/core/streaming.d.mts.map +1 -0
  14. package/core/streaming.d.ts +33 -0
  15. package/core/streaming.d.ts.map +1 -0
  16. package/core/streaming.js +263 -0
  17. package/core/streaming.js.map +1 -0
  18. package/core/streaming.mjs +258 -0
  19. package/core/streaming.mjs.map +1 -0
  20. package/internal/decoders/line.d.mts +17 -0
  21. package/internal/decoders/line.d.mts.map +1 -0
  22. package/internal/decoders/line.d.ts +17 -0
  23. package/internal/decoders/line.d.ts.map +1 -0
  24. package/internal/decoders/line.js +113 -0
  25. package/internal/decoders/line.js.map +1 -0
  26. package/internal/decoders/line.mjs +108 -0
  27. package/internal/decoders/line.mjs.map +1 -0
  28. package/internal/parse.d.mts.map +1 -1
  29. package/internal/parse.d.ts.map +1 -1
  30. package/internal/parse.js +10 -0
  31. package/internal/parse.js.map +1 -1
  32. package/internal/parse.mjs +10 -0
  33. package/internal/parse.mjs.map +1 -1
  34. package/internal/request-options.d.mts +44 -0
  35. package/internal/request-options.d.mts.map +1 -1
  36. package/internal/request-options.d.ts +44 -0
  37. package/internal/request-options.d.ts.map +1 -1
  38. package/internal/request-options.js.map +1 -1
  39. package/internal/request-options.mjs.map +1 -1
  40. package/internal/tslib.js +6 -6
  41. package/internal/types.d.mts +8 -6
  42. package/internal/types.d.mts.map +1 -1
  43. package/internal/types.d.ts +8 -6
  44. package/internal/types.d.ts.map +1 -1
  45. package/internal/uploads.js +1 -1
  46. package/internal/uploads.js.map +1 -1
  47. package/internal/uploads.mjs +1 -1
  48. package/internal/uploads.mjs.map +1 -1
  49. package/internal/utils/log.js +1 -1
  50. package/internal/utils/log.js.map +1 -1
  51. package/internal/utils/log.mjs +1 -1
  52. package/internal/utils/log.mjs.map +1 -1
  53. package/internal/utils/path.d.mts.map +1 -1
  54. package/internal/utils/path.d.ts.map +1 -1
  55. package/internal/utils/path.js +26 -5
  56. package/internal/utils/path.js.map +1 -1
  57. package/internal/utils/path.mjs +26 -5
  58. package/internal/utils/path.mjs.map +1 -1
  59. package/package.json +13 -3
  60. package/resources/app.d.mts +130 -0
  61. package/resources/app.d.mts.map +1 -0
  62. package/resources/app.d.ts +130 -0
  63. package/resources/app.d.ts.map +1 -0
  64. package/resources/app.js +39 -0
  65. package/resources/app.js.map +1 -0
  66. package/resources/app.mjs +35 -0
  67. package/resources/app.mjs.map +1 -0
  68. package/resources/config.d.mts +344 -0
  69. package/resources/config.d.mts.map +1 -0
  70. package/resources/config.d.ts +344 -0
  71. package/resources/config.d.ts.map +1 -0
  72. package/resources/{config-get.js → config.js} +6 -6
  73. package/resources/config.js.map +1 -0
  74. package/resources/{config-get.mjs → config.mjs} +4 -4
  75. package/resources/config.mjs.map +1 -0
  76. package/resources/event.d.mts +82 -29
  77. package/resources/event.d.mts.map +1 -1
  78. package/resources/event.d.ts +82 -29
  79. package/resources/event.d.ts.map +1 -1
  80. package/resources/event.js +1 -1
  81. package/resources/event.js.map +1 -1
  82. package/resources/event.mjs +1 -1
  83. package/resources/event.mjs.map +1 -1
  84. package/resources/file.d.mts +31 -0
  85. package/resources/file.d.mts.map +1 -0
  86. package/resources/file.d.ts +31 -0
  87. package/resources/file.d.ts.map +1 -0
  88. package/resources/file.js +21 -0
  89. package/resources/file.js.map +1 -0
  90. package/resources/file.mjs +17 -0
  91. package/resources/file.mjs.map +1 -0
  92. package/resources/find.d.mts +85 -0
  93. package/resources/find.d.mts.map +1 -0
  94. package/resources/find.d.ts +85 -0
  95. package/resources/find.d.ts.map +1 -0
  96. package/resources/find.js +27 -0
  97. package/resources/find.js.map +1 -0
  98. package/resources/find.mjs +23 -0
  99. package/resources/find.mjs.map +1 -0
  100. package/resources/index.d.mts +6 -16
  101. package/resources/index.d.mts.map +1 -1
  102. package/resources/index.d.ts +6 -16
  103. package/resources/index.d.ts.map +1 -1
  104. package/resources/index.js +13 -33
  105. package/resources/index.js.map +1 -1
  106. package/resources/index.mjs +6 -16
  107. package/resources/index.mjs.map +1 -1
  108. package/resources/session.d.mts +272 -0
  109. package/resources/session.d.mts.map +1 -0
  110. package/resources/session.d.ts +272 -0
  111. package/resources/session.d.ts.map +1 -0
  112. package/resources/session.js +70 -0
  113. package/resources/session.js.map +1 -0
  114. package/resources/session.mjs +66 -0
  115. package/resources/session.mjs.map +1 -0
  116. package/resources/shared.d.mts +24 -0
  117. package/resources/shared.d.mts.map +1 -0
  118. package/resources/shared.d.ts +24 -0
  119. package/resources/shared.d.ts.map +1 -0
  120. package/resources/shared.js +4 -0
  121. package/resources/shared.js.map +1 -0
  122. package/resources/shared.mjs +3 -0
  123. package/resources/shared.mjs.map +1 -0
  124. package/src/client.ts +145 -128
  125. package/src/core/streaming.ts +315 -0
  126. package/src/internal/decoders/line.ts +135 -0
  127. package/src/internal/parse.ts +14 -0
  128. package/src/internal/request-options.ts +55 -0
  129. package/src/internal/types.ts +9 -6
  130. package/src/internal/uploads.ts +1 -1
  131. package/src/internal/utils/log.ts +1 -1
  132. package/src/internal/utils/path.ts +32 -7
  133. package/src/resources/app.ts +196 -0
  134. package/src/resources/config.ts +431 -0
  135. package/src/resources/event.ts +119 -39
  136. package/src/resources/file.ts +52 -0
  137. package/src/resources/find.ts +133 -0
  138. package/src/resources/index.ts +65 -32
  139. package/src/resources/session.ts +457 -0
  140. package/src/resources/shared.ts +33 -0
  141. package/src/streaming.ts +2 -0
  142. package/src/version.ts +1 -1
  143. package/streaming.d.mts +2 -0
  144. package/streaming.d.mts.map +1 -0
  145. package/streaming.d.ts +2 -0
  146. package/streaming.d.ts.map +1 -0
  147. package/streaming.js +6 -0
  148. package/streaming.js.map +1 -0
  149. package/streaming.mjs +2 -0
  150. package/streaming.mjs.map +1 -0
  151. package/version.d.mts +1 -1
  152. package/version.d.mts.map +1 -1
  153. package/version.d.ts +1 -1
  154. package/version.d.ts.map +1 -1
  155. package/version.js +1 -1
  156. package/version.js.map +1 -1
  157. package/version.mjs +1 -1
  158. package/version.mjs.map +1 -1
  159. package/resources/app-info.d.mts +0 -31
  160. package/resources/app-info.d.mts.map +0 -1
  161. package/resources/app-info.d.ts +0 -31
  162. package/resources/app-info.d.ts.map +0 -1
  163. package/resources/app-info.js +0 -15
  164. package/resources/app-info.js.map +0 -1
  165. package/resources/app-info.mjs +0 -11
  166. package/resources/app-info.mjs.map +0 -1
  167. package/resources/app-initialize.d.mts +0 -14
  168. package/resources/app-initialize.d.mts.map +0 -1
  169. package/resources/app-initialize.d.ts +0 -14
  170. package/resources/app-initialize.d.ts.map +0 -1
  171. package/resources/app-initialize.js +0 -15
  172. package/resources/app-initialize.js.map +0 -1
  173. package/resources/app-initialize.mjs +0 -11
  174. package/resources/app-initialize.mjs.map +0 -1
  175. package/resources/config-get.d.mts +0 -236
  176. package/resources/config-get.d.mts.map +0 -1
  177. package/resources/config-get.d.ts +0 -236
  178. package/resources/config-get.d.ts.map +0 -1
  179. package/resources/config-get.js.map +0 -1
  180. package/resources/config-get.mjs.map +0 -1
  181. package/resources/file-search.d.mts +0 -17
  182. package/resources/file-search.d.mts.map +0 -1
  183. package/resources/file-search.d.ts +0 -17
  184. package/resources/file-search.d.ts.map +0 -1
  185. package/resources/file-search.js +0 -15
  186. package/resources/file-search.js.map +0 -1
  187. package/resources/file-search.mjs +0 -11
  188. package/resources/file-search.mjs.map +0 -1
  189. package/resources/installation-info.d.mts +0 -17
  190. package/resources/installation-info.d.mts.map +0 -1
  191. package/resources/installation-info.d.ts +0 -17
  192. package/resources/installation-info.d.ts.map +0 -1
  193. package/resources/installation-info.js +0 -15
  194. package/resources/installation-info.js.map +0 -1
  195. package/resources/installation-info.mjs +0 -11
  196. package/resources/installation-info.mjs.map +0 -1
  197. package/resources/path-get.d.mts +0 -19
  198. package/resources/path-get.d.mts.map +0 -1
  199. package/resources/path-get.d.ts +0 -19
  200. package/resources/path-get.d.ts.map +0 -1
  201. package/resources/path-get.js +0 -15
  202. package/resources/path-get.js.map +0 -1
  203. package/resources/path-get.mjs +0 -11
  204. package/resources/path-get.mjs.map +0 -1
  205. package/resources/provider-list.d.mts +0 -58
  206. package/resources/provider-list.d.mts.map +0 -1
  207. package/resources/provider-list.d.ts +0 -58
  208. package/resources/provider-list.d.ts.map +0 -1
  209. package/resources/provider-list.js +0 -15
  210. package/resources/provider-list.js.map +0 -1
  211. package/resources/provider-list.mjs +0 -11
  212. package/resources/provider-list.mjs.map +0 -1
  213. package/resources/session-abort.d.mts +0 -17
  214. package/resources/session-abort.d.mts.map +0 -1
  215. package/resources/session-abort.d.ts +0 -17
  216. package/resources/session-abort.d.ts.map +0 -1
  217. package/resources/session-abort.js +0 -15
  218. package/resources/session-abort.js.map +0 -1
  219. package/resources/session-abort.mjs +0 -11
  220. package/resources/session-abort.mjs.map +0 -1
  221. package/resources/session-chat.d.mts +0 -160
  222. package/resources/session-chat.d.mts.map +0 -1
  223. package/resources/session-chat.d.ts +0 -160
  224. package/resources/session-chat.d.ts.map +0 -1
  225. package/resources/session-chat.js +0 -15
  226. package/resources/session-chat.js.map +0 -1
  227. package/resources/session-chat.mjs +0 -11
  228. package/resources/session-chat.mjs.map +0 -1
  229. package/resources/session-create.d.mts +0 -30
  230. package/resources/session-create.d.mts.map +0 -1
  231. package/resources/session-create.d.ts +0 -30
  232. package/resources/session-create.d.ts.map +0 -1
  233. package/resources/session-create.js +0 -15
  234. package/resources/session-create.js.map +0 -1
  235. package/resources/session-create.mjs +0 -11
  236. package/resources/session-create.mjs.map +0 -1
  237. package/resources/session-initialize.d.mts +0 -19
  238. package/resources/session-initialize.d.mts.map +0 -1
  239. package/resources/session-initialize.d.ts +0 -19
  240. package/resources/session-initialize.d.ts.map +0 -1
  241. package/resources/session-initialize.js +0 -15
  242. package/resources/session-initialize.js.map +0 -1
  243. package/resources/session-initialize.mjs +0 -11
  244. package/resources/session-initialize.mjs.map +0 -1
  245. package/resources/session-list.d.mts +0 -15
  246. package/resources/session-list.d.mts.map +0 -1
  247. package/resources/session-list.d.ts +0 -15
  248. package/resources/session-list.d.ts.map +0 -1
  249. package/resources/session-list.js +0 -15
  250. package/resources/session-list.js.map +0 -1
  251. package/resources/session-list.mjs +0 -11
  252. package/resources/session-list.mjs.map +0 -1
  253. package/resources/session-messages.d.mts +0 -18
  254. package/resources/session-messages.d.mts.map +0 -1
  255. package/resources/session-messages.d.ts +0 -18
  256. package/resources/session-messages.d.ts.map +0 -1
  257. package/resources/session-messages.js +0 -15
  258. package/resources/session-messages.js.map +0 -1
  259. package/resources/session-messages.mjs +0 -11
  260. package/resources/session-messages.mjs.map +0 -1
  261. package/resources/session-share.d.mts +0 -17
  262. package/resources/session-share.d.mts.map +0 -1
  263. package/resources/session-share.d.ts +0 -17
  264. package/resources/session-share.d.ts.map +0 -1
  265. package/resources/session-share.js +0 -15
  266. package/resources/session-share.js.map +0 -1
  267. package/resources/session-share.mjs +0 -11
  268. package/resources/session-share.mjs.map +0 -1
  269. package/resources/session-summarize.d.mts +0 -19
  270. package/resources/session-summarize.d.mts.map +0 -1
  271. package/resources/session-summarize.d.ts +0 -19
  272. package/resources/session-summarize.d.ts.map +0 -1
  273. package/resources/session-summarize.js +0 -15
  274. package/resources/session-summarize.js.map +0 -1
  275. package/resources/session-summarize.mjs +0 -11
  276. package/resources/session-summarize.mjs.map +0 -1
  277. package/resources/session-unshare.d.mts +0 -17
  278. package/resources/session-unshare.d.mts.map +0 -1
  279. package/resources/session-unshare.d.ts +0 -17
  280. package/resources/session-unshare.d.ts.map +0 -1
  281. package/resources/session-unshare.js +0 -15
  282. package/resources/session-unshare.js.map +0 -1
  283. package/resources/session-unshare.mjs +0 -11
  284. package/resources/session-unshare.mjs.map +0 -1
  285. package/src/resources/app-info.ts +0 -46
  286. package/src/resources/app-initialize.ts +0 -20
  287. package/src/resources/config-get.ts +0 -294
  288. package/src/resources/file-search.ts +0 -27
  289. package/src/resources/installation-info.ts +0 -24
  290. package/src/resources/path-get.ts +0 -28
  291. package/src/resources/provider-list.ts +0 -80
  292. package/src/resources/session-abort.ts +0 -27
  293. package/src/resources/session-chat.ts +0 -250
  294. package/src/resources/session-create.ts +0 -44
  295. package/src/resources/session-initialize.ts +0 -34
  296. package/src/resources/session-list.ts +0 -21
  297. package/src/resources/session-messages.ts +0 -31
  298. package/src/resources/session-share.ts +0 -23
  299. package/src/resources/session-summarize.ts +0 -34
  300. package/src/resources/session-unshare.ts +0 -26
@@ -12,25 +12,43 @@ export function encodeURIPath(str: string) {
12
12
  return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
13
13
  }
14
14
 
15
+ const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
16
+
15
17
  export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
16
18
  function path(statics: readonly string[], ...params: readonly unknown[]): string {
17
19
  // If there are no params, no processing is needed.
18
20
  if (statics.length === 1) return statics[0]!;
19
21
 
20
22
  let postPath = false;
23
+ const invalidSegments = [];
21
24
  const path = statics.reduce((previousValue, currentValue, index) => {
22
25
  if (/[?#]/.test(currentValue)) {
23
26
  postPath = true;
24
27
  }
25
- return (
26
- previousValue +
27
- currentValue +
28
- (index === params.length ? '' : (postPath ? encodeURIComponent : pathEncoder)(String(params[index])))
29
- );
28
+ const value = params[index];
29
+ let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value);
30
+ if (
31
+ index !== params.length &&
32
+ (value == null ||
33
+ (typeof value === 'object' &&
34
+ // handle values from other realms
35
+ value.toString ===
36
+ Object.getPrototypeOf(Object.getPrototypeOf((value as any).hasOwnProperty ?? EMPTY) ?? EMPTY)
37
+ ?.toString))
38
+ ) {
39
+ encoded = value + '';
40
+ invalidSegments.push({
41
+ start: previousValue.length + currentValue.length,
42
+ length: encoded.length,
43
+ error: `Value of type ${Object.prototype.toString
44
+ .call(value)
45
+ .slice(8, -1)} is not a valid path parameter`,
46
+ });
47
+ }
48
+ return previousValue + currentValue + (index === params.length ? '' : encoded);
30
49
  }, '');
31
50
 
32
51
  const pathOnly = path.split(/[?#]/, 1)[0]!;
33
- const invalidSegments = [];
34
52
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
35
53
  let match;
36
54
 
@@ -39,9 +57,12 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
39
57
  invalidSegments.push({
40
58
  start: match.index,
41
59
  length: match[0].length,
60
+ error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
42
61
  });
43
62
  }
44
63
 
64
+ invalidSegments.sort((a, b) => a.start - b.start);
65
+
45
66
  if (invalidSegments.length > 0) {
46
67
  let lastEnd = 0;
47
68
  const underline = invalidSegments.reduce((acc, segment) => {
@@ -51,7 +72,11 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
51
72
  return acc + spaces + arrows;
52
73
  }, '');
53
74
 
54
- throw new OpencodeError(`Path parameters result in path with invalid segments:\n${path}\n${underline}`);
75
+ throw new OpencodeError(
76
+ `Path parameters result in path with invalid segments:\n${invalidSegments
77
+ .map((e) => e.error)
78
+ .join('\n')}\n${path}\n${underline}`,
79
+ );
55
80
  }
56
81
 
57
82
  return path;
@@ -0,0 +1,196 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+
7
+ export class AppResource extends APIResource {
8
+ /**
9
+ * Get app info
10
+ */
11
+ get(options?: RequestOptions): APIPromise<App> {
12
+ return this._client.get('/app', options);
13
+ }
14
+
15
+ /**
16
+ * Initialize the app
17
+ */
18
+ init(options?: RequestOptions): APIPromise<AppInitResponse> {
19
+ return this._client.post('/app/init', options);
20
+ }
21
+
22
+ /**
23
+ * Write a log entry to the server logs
24
+ */
25
+ log(body: AppLogParams, options?: RequestOptions): APIPromise<AppLogResponse> {
26
+ return this._client.post('/log', { body, ...options });
27
+ }
28
+
29
+ /**
30
+ * List all modes
31
+ */
32
+ modes(options?: RequestOptions): APIPromise<AppModesResponse> {
33
+ return this._client.get('/mode', options);
34
+ }
35
+
36
+ /**
37
+ * List all providers
38
+ */
39
+ providers(options?: RequestOptions): APIPromise<AppProvidersResponse> {
40
+ return this._client.get('/config/providers', options);
41
+ }
42
+ }
43
+
44
+ export interface App {
45
+ git: boolean;
46
+
47
+ hostname: string;
48
+
49
+ path: App.Path;
50
+
51
+ time: App.Time;
52
+ }
53
+
54
+ export namespace App {
55
+ export interface Path {
56
+ config: string;
57
+
58
+ cwd: string;
59
+
60
+ data: string;
61
+
62
+ root: string;
63
+
64
+ state: string;
65
+ }
66
+
67
+ export interface Time {
68
+ initialized?: number;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Log level
74
+ */
75
+ export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
76
+
77
+ export interface Mode {
78
+ name: string;
79
+
80
+ tools: { [key: string]: boolean };
81
+
82
+ model?: Mode.Model;
83
+
84
+ prompt?: string;
85
+ }
86
+
87
+ export namespace Mode {
88
+ export interface Model {
89
+ modelID: string;
90
+
91
+ providerID: string;
92
+ }
93
+ }
94
+
95
+ export interface Model {
96
+ id: string;
97
+
98
+ attachment: boolean;
99
+
100
+ cost: Model.Cost;
101
+
102
+ limit: Model.Limit;
103
+
104
+ name: string;
105
+
106
+ options: { [key: string]: unknown };
107
+
108
+ reasoning: boolean;
109
+
110
+ release_date: string;
111
+
112
+ temperature: boolean;
113
+
114
+ tool_call: boolean;
115
+ }
116
+
117
+ export namespace Model {
118
+ export interface Cost {
119
+ input: number;
120
+
121
+ output: number;
122
+
123
+ cache_read?: number;
124
+
125
+ cache_write?: number;
126
+ }
127
+
128
+ export interface Limit {
129
+ context: number;
130
+
131
+ output: number;
132
+ }
133
+ }
134
+
135
+ export interface Provider {
136
+ id: string;
137
+
138
+ env: Array<string>;
139
+
140
+ models: { [key: string]: Model };
141
+
142
+ name: string;
143
+
144
+ api?: string;
145
+
146
+ npm?: string;
147
+ }
148
+
149
+ export type AppInitResponse = boolean;
150
+
151
+ export type AppLogResponse = boolean;
152
+
153
+ export type AppModesResponse = Array<Mode>;
154
+
155
+ export interface AppProvidersResponse {
156
+ default: { [key: string]: string };
157
+
158
+ providers: Array<Provider>;
159
+ }
160
+
161
+ export interface AppLogParams {
162
+ /**
163
+ * Log level
164
+ */
165
+ level: 'debug' | 'info' | 'error' | 'warn';
166
+
167
+ /**
168
+ * Log message
169
+ */
170
+ message: string;
171
+
172
+ /**
173
+ * Service name for the log entry
174
+ */
175
+ service: string;
176
+
177
+ /**
178
+ * Additional metadata for the log entry
179
+ */
180
+ extra?: { [key: string]: unknown };
181
+ }
182
+
183
+ export declare namespace AppResource {
184
+ export {
185
+ type App as App,
186
+ type LogLevel as LogLevel,
187
+ type Mode as Mode,
188
+ type Model as Model,
189
+ type Provider as Provider,
190
+ type AppInitResponse as AppInitResponse,
191
+ type AppLogResponse as AppLogResponse,
192
+ type AppModesResponse as AppModesResponse,
193
+ type AppProvidersResponse as AppProvidersResponse,
194
+ type AppLogParams as AppLogParams,
195
+ };
196
+ }
@@ -0,0 +1,431 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as ConfigAPI from './config';
5
+ import * as AppAPI from './app';
6
+ import { APIPromise } from '../core/api-promise';
7
+ import { RequestOptions } from '../internal/request-options';
8
+
9
+ export class ConfigResource extends APIResource {
10
+ /**
11
+ * Get config info
12
+ */
13
+ get(options?: RequestOptions): APIPromise<Config> {
14
+ return this._client.get('/config', options);
15
+ }
16
+ }
17
+
18
+ export interface Config {
19
+ /**
20
+ * JSON schema reference for configuration validation
21
+ */
22
+ $schema?: string;
23
+
24
+ /**
25
+ * @deprecated Use 'share' field instead. Share newly created sessions
26
+ * automatically
27
+ */
28
+ autoshare?: boolean;
29
+
30
+ /**
31
+ * Automatically update to the latest version
32
+ */
33
+ autoupdate?: boolean;
34
+
35
+ /**
36
+ * Disable providers that are loaded automatically
37
+ */
38
+ disabled_providers?: Array<string>;
39
+
40
+ experimental?: Config.Experimental;
41
+
42
+ /**
43
+ * Additional instruction files or patterns to include
44
+ */
45
+ instructions?: Array<string>;
46
+
47
+ /**
48
+ * Custom keybind configurations
49
+ */
50
+ keybinds?: KeybindsConfig;
51
+
52
+ /**
53
+ * Layout to use for the TUI
54
+ */
55
+ layout?: LayoutConfig;
56
+
57
+ /**
58
+ * Minimum log level to write to log files
59
+ */
60
+ log_level?: AppAPI.LogLevel;
61
+
62
+ /**
63
+ * MCP (Model Context Protocol) server configurations
64
+ */
65
+ mcp?: { [key: string]: McpLocalConfig | McpRemoteConfig };
66
+
67
+ /**
68
+ * Modes configuration, see https://opencode.ai/docs/modes
69
+ */
70
+ mode?: Config.Mode;
71
+
72
+ /**
73
+ * Model to use in the format of provider/model, eg anthropic/claude-2
74
+ */
75
+ model?: string;
76
+
77
+ /**
78
+ * Custom provider configurations and model overrides
79
+ */
80
+ provider?: { [key: string]: Config.Provider };
81
+
82
+ /**
83
+ * Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
84
+ * all sharing
85
+ */
86
+ share?: 'auto' | 'disabled';
87
+
88
+ /**
89
+ * Theme name to use for the interface
90
+ */
91
+ theme?: string;
92
+
93
+ /**
94
+ * Custom username to display in conversations instead of system username
95
+ */
96
+ username?: string;
97
+ }
98
+
99
+ export namespace Config {
100
+ export interface Experimental {
101
+ hook?: Experimental.Hook;
102
+ }
103
+
104
+ export namespace Experimental {
105
+ export interface Hook {
106
+ file_edited?: { [key: string]: Array<Hook.FileEdited> };
107
+
108
+ session_completed?: Array<Hook.SessionCompleted>;
109
+ }
110
+
111
+ export namespace Hook {
112
+ export interface FileEdited {
113
+ command: Array<string>;
114
+
115
+ environment?: { [key: string]: string };
116
+ }
117
+
118
+ export interface SessionCompleted {
119
+ command: Array<string>;
120
+
121
+ environment?: { [key: string]: string };
122
+ }
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Modes configuration, see https://opencode.ai/docs/modes
128
+ */
129
+ export interface Mode {
130
+ build?: ConfigAPI.ModeConfig;
131
+
132
+ plan?: ConfigAPI.ModeConfig;
133
+
134
+ [k: string]: ConfigAPI.ModeConfig | undefined;
135
+ }
136
+
137
+ export interface Provider {
138
+ models: { [key: string]: Provider.Models };
139
+
140
+ id?: string;
141
+
142
+ api?: string;
143
+
144
+ env?: Array<string>;
145
+
146
+ name?: string;
147
+
148
+ npm?: string;
149
+
150
+ options?: { [key: string]: unknown };
151
+ }
152
+
153
+ export namespace Provider {
154
+ export interface Models {
155
+ id?: string;
156
+
157
+ attachment?: boolean;
158
+
159
+ cost?: Models.Cost;
160
+
161
+ limit?: Models.Limit;
162
+
163
+ name?: string;
164
+
165
+ options?: { [key: string]: unknown };
166
+
167
+ reasoning?: boolean;
168
+
169
+ release_date?: string;
170
+
171
+ temperature?: boolean;
172
+
173
+ tool_call?: boolean;
174
+ }
175
+
176
+ export namespace Models {
177
+ export interface Cost {
178
+ input: number;
179
+
180
+ output: number;
181
+
182
+ cache_read?: number;
183
+
184
+ cache_write?: number;
185
+ }
186
+
187
+ export interface Limit {
188
+ context: number;
189
+
190
+ output: number;
191
+ }
192
+ }
193
+ }
194
+ }
195
+
196
+ export interface KeybindsConfig {
197
+ /**
198
+ * Exit the application
199
+ */
200
+ app_exit: string;
201
+
202
+ /**
203
+ * Show help dialog
204
+ */
205
+ app_help: string;
206
+
207
+ /**
208
+ * Open external editor
209
+ */
210
+ editor_open: string;
211
+
212
+ /**
213
+ * Close file
214
+ */
215
+ file_close: string;
216
+
217
+ /**
218
+ * Split/unified diff
219
+ */
220
+ file_diff_toggle: string;
221
+
222
+ /**
223
+ * List files
224
+ */
225
+ file_list: string;
226
+
227
+ /**
228
+ * Search file
229
+ */
230
+ file_search: string;
231
+
232
+ /**
233
+ * Clear input field
234
+ */
235
+ input_clear: string;
236
+
237
+ /**
238
+ * Insert newline in input
239
+ */
240
+ input_newline: string;
241
+
242
+ /**
243
+ * Paste from clipboard
244
+ */
245
+ input_paste: string;
246
+
247
+ /**
248
+ * Submit input
249
+ */
250
+ input_submit: string;
251
+
252
+ /**
253
+ * Leader key for keybind combinations
254
+ */
255
+ leader: string;
256
+
257
+ /**
258
+ * Copy message
259
+ */
260
+ messages_copy: string;
261
+
262
+ /**
263
+ * Navigate to first message
264
+ */
265
+ messages_first: string;
266
+
267
+ /**
268
+ * Scroll messages down by half page
269
+ */
270
+ messages_half_page_down: string;
271
+
272
+ /**
273
+ * Scroll messages up by half page
274
+ */
275
+ messages_half_page_up: string;
276
+
277
+ /**
278
+ * Navigate to last message
279
+ */
280
+ messages_last: string;
281
+
282
+ /**
283
+ * Toggle layout
284
+ */
285
+ messages_layout_toggle: string;
286
+
287
+ /**
288
+ * Navigate to next message
289
+ */
290
+ messages_next: string;
291
+
292
+ /**
293
+ * Scroll messages down by one page
294
+ */
295
+ messages_page_down: string;
296
+
297
+ /**
298
+ * Scroll messages up by one page
299
+ */
300
+ messages_page_up: string;
301
+
302
+ /**
303
+ * Navigate to previous message
304
+ */
305
+ messages_previous: string;
306
+
307
+ /**
308
+ * Revert message
309
+ */
310
+ messages_revert: string;
311
+
312
+ /**
313
+ * List available models
314
+ */
315
+ model_list: string;
316
+
317
+ /**
318
+ * Create/update AGENTS.md
319
+ */
320
+ project_init: string;
321
+
322
+ /**
323
+ * Compact the session
324
+ */
325
+ session_compact: string;
326
+
327
+ /**
328
+ * Export session to editor
329
+ */
330
+ session_export: string;
331
+
332
+ /**
333
+ * Interrupt current session
334
+ */
335
+ session_interrupt: string;
336
+
337
+ /**
338
+ * List all sessions
339
+ */
340
+ session_list: string;
341
+
342
+ /**
343
+ * Create a new session
344
+ */
345
+ session_new: string;
346
+
347
+ /**
348
+ * Share current session
349
+ */
350
+ session_share: string;
351
+
352
+ /**
353
+ * Unshare current session
354
+ */
355
+ session_unshare: string;
356
+
357
+ /**
358
+ * Switch mode
359
+ */
360
+ switch_mode: string;
361
+
362
+ /**
363
+ * List available themes
364
+ */
365
+ theme_list: string;
366
+
367
+ /**
368
+ * Toggle tool details
369
+ */
370
+ tool_details: string;
371
+ }
372
+
373
+ export type LayoutConfig = 'auto' | 'stretch';
374
+
375
+ export interface McpLocalConfig {
376
+ /**
377
+ * Command and arguments to run the MCP server
378
+ */
379
+ command: Array<string>;
380
+
381
+ /**
382
+ * Type of MCP server connection
383
+ */
384
+ type: 'local';
385
+
386
+ /**
387
+ * Enable or disable the MCP server on startup
388
+ */
389
+ enabled?: boolean;
390
+
391
+ /**
392
+ * Environment variables to set when running the MCP server
393
+ */
394
+ environment?: { [key: string]: string };
395
+ }
396
+
397
+ export interface McpRemoteConfig {
398
+ /**
399
+ * Type of MCP server connection
400
+ */
401
+ type: 'remote';
402
+
403
+ /**
404
+ * URL of the remote MCP server
405
+ */
406
+ url: string;
407
+
408
+ /**
409
+ * Enable or disable the MCP server on startup
410
+ */
411
+ enabled?: boolean;
412
+ }
413
+
414
+ export interface ModeConfig {
415
+ model?: string;
416
+
417
+ prompt?: string;
418
+
419
+ tools?: { [key: string]: boolean };
420
+ }
421
+
422
+ export declare namespace ConfigResource {
423
+ export {
424
+ type Config as Config,
425
+ type KeybindsConfig as KeybindsConfig,
426
+ type LayoutConfig as LayoutConfig,
427
+ type McpLocalConfig as McpLocalConfig,
428
+ type McpRemoteConfig as McpRemoteConfig,
429
+ type ModeConfig as ModeConfig,
430
+ };
431
+ }