@opencode-ai/sdk 0.0.1
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.
- package/dist/gen/client/client.d.ts +2 -0
- package/dist/gen/client/client.js +145 -0
- package/dist/gen/client/index.d.ts +7 -0
- package/dist/gen/client/index.js +4 -0
- package/dist/gen/client/types.d.ts +119 -0
- package/dist/gen/client/types.js +0 -0
- package/dist/gen/client/utils.d.ts +45 -0
- package/dist/gen/client/utils.js +284 -0
- package/dist/gen/client.gen.d.ts +12 -0
- package/dist/gen/client.gen.js +5 -0
- package/dist/gen/core/auth.d.ts +18 -0
- package/dist/gen/core/auth.js +13 -0
- package/dist/gen/core/bodySerializer.d.ts +17 -0
- package/dist/gen/core/bodySerializer.js +53 -0
- package/dist/gen/core/params.d.ts +33 -0
- package/dist/gen/core/params.js +87 -0
- package/dist/gen/core/pathSerializer.d.ts +33 -0
- package/dist/gen/core/pathSerializer.js +113 -0
- package/dist/gen/core/types.d.ts +78 -0
- package/dist/gen/core/types.js +0 -0
- package/dist/gen/sdk.gen.d.ts +149 -0
- package/dist/gen/sdk.gen.js +291 -0
- package/dist/gen/types.gen.d.ts +1308 -0
- package/dist/gen/types.gen.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/script/generate.js +31 -0
- package/dist/script/publish.js +4 -0
- package/dist/src/gen/client/client.js +145 -0
- package/dist/src/gen/client/index.js +4 -0
- package/dist/src/gen/client/types.js +0 -0
- package/dist/src/gen/client/utils.js +284 -0
- package/dist/src/gen/client.gen.js +5 -0
- package/dist/src/gen/core/auth.js +13 -0
- package/dist/src/gen/core/bodySerializer.js +53 -0
- package/dist/src/gen/core/params.js +87 -0
- package/dist/src/gen/core/pathSerializer.js +113 -0
- package/dist/src/gen/core/types.js +0 -0
- package/dist/src/gen/sdk.gen.js +291 -0
- package/dist/src/gen/types.gen.js +1 -0
- package/dist/src/index.js +6 -0
- package/package.json +17 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export const separatorArrayExplode = (style) => {
|
|
2
|
+
switch (style) {
|
|
3
|
+
case 'label':
|
|
4
|
+
return '.';
|
|
5
|
+
case 'matrix':
|
|
6
|
+
return ';';
|
|
7
|
+
case 'simple':
|
|
8
|
+
return ',';
|
|
9
|
+
default:
|
|
10
|
+
return '&';
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export const separatorArrayNoExplode = (style) => {
|
|
14
|
+
switch (style) {
|
|
15
|
+
case 'form':
|
|
16
|
+
return ',';
|
|
17
|
+
case 'pipeDelimited':
|
|
18
|
+
return '|';
|
|
19
|
+
case 'spaceDelimited':
|
|
20
|
+
return '%20';
|
|
21
|
+
default:
|
|
22
|
+
return ',';
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export const separatorObjectExplode = (style) => {
|
|
26
|
+
switch (style) {
|
|
27
|
+
case 'label':
|
|
28
|
+
return '.';
|
|
29
|
+
case 'matrix':
|
|
30
|
+
return ';';
|
|
31
|
+
case 'simple':
|
|
32
|
+
return ',';
|
|
33
|
+
default:
|
|
34
|
+
return '&';
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const serializeArrayParam = ({ allowReserved, explode, name, style, value, }) => {
|
|
38
|
+
if (!explode) {
|
|
39
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
40
|
+
switch (style) {
|
|
41
|
+
case 'label':
|
|
42
|
+
return `.${joinedValues}`;
|
|
43
|
+
case 'matrix':
|
|
44
|
+
return `;${name}=${joinedValues}`;
|
|
45
|
+
case 'simple':
|
|
46
|
+
return joinedValues;
|
|
47
|
+
default:
|
|
48
|
+
return `${name}=${joinedValues}`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const separator = separatorArrayExplode(style);
|
|
52
|
+
const joinedValues = value
|
|
53
|
+
.map((v) => {
|
|
54
|
+
if (style === 'label' || style === 'simple') {
|
|
55
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
56
|
+
}
|
|
57
|
+
return serializePrimitiveParam({
|
|
58
|
+
allowReserved,
|
|
59
|
+
name,
|
|
60
|
+
value: v,
|
|
61
|
+
});
|
|
62
|
+
})
|
|
63
|
+
.join(separator);
|
|
64
|
+
return style === 'label' || style === 'matrix'
|
|
65
|
+
? separator + joinedValues
|
|
66
|
+
: joinedValues;
|
|
67
|
+
};
|
|
68
|
+
export const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
|
|
69
|
+
if (value === undefined || value === null) {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
if (typeof value === 'object') {
|
|
73
|
+
throw new Error('Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.');
|
|
74
|
+
}
|
|
75
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
76
|
+
};
|
|
77
|
+
export const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly, }) => {
|
|
78
|
+
if (value instanceof Date) {
|
|
79
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
80
|
+
}
|
|
81
|
+
if (style !== 'deepObject' && !explode) {
|
|
82
|
+
let values = [];
|
|
83
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
84
|
+
values = [
|
|
85
|
+
...values,
|
|
86
|
+
key,
|
|
87
|
+
allowReserved ? v : encodeURIComponent(v),
|
|
88
|
+
];
|
|
89
|
+
});
|
|
90
|
+
const joinedValues = values.join(',');
|
|
91
|
+
switch (style) {
|
|
92
|
+
case 'form':
|
|
93
|
+
return `${name}=${joinedValues}`;
|
|
94
|
+
case 'label':
|
|
95
|
+
return `.${joinedValues}`;
|
|
96
|
+
case 'matrix':
|
|
97
|
+
return `;${name}=${joinedValues}`;
|
|
98
|
+
default:
|
|
99
|
+
return joinedValues;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const separator = separatorObjectExplode(style);
|
|
103
|
+
const joinedValues = Object.entries(value)
|
|
104
|
+
.map(([key, v]) => serializePrimitiveParam({
|
|
105
|
+
allowReserved,
|
|
106
|
+
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
|
107
|
+
value: v,
|
|
108
|
+
}))
|
|
109
|
+
.join(separator);
|
|
110
|
+
return style === 'label' || style === 'matrix'
|
|
111
|
+
? separator + joinedValues
|
|
112
|
+
: joinedValues;
|
|
113
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
import { client as _heyApiClient } from './client.gen';
|
|
3
|
+
class _HeyApiClient {
|
|
4
|
+
_client = _heyApiClient;
|
|
5
|
+
constructor(args) {
|
|
6
|
+
if (args?.client) {
|
|
7
|
+
this._client = args.client;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
class Event extends _HeyApiClient {
|
|
12
|
+
/**
|
|
13
|
+
* Get events
|
|
14
|
+
*/
|
|
15
|
+
subscribe(options) {
|
|
16
|
+
return (options?.client ?? this._client).get({
|
|
17
|
+
url: '/event',
|
|
18
|
+
...options
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
class App extends _HeyApiClient {
|
|
23
|
+
/**
|
|
24
|
+
* Get app info
|
|
25
|
+
*/
|
|
26
|
+
get(options) {
|
|
27
|
+
return (options?.client ?? this._client).get({
|
|
28
|
+
url: '/app',
|
|
29
|
+
...options
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the app
|
|
34
|
+
*/
|
|
35
|
+
init(options) {
|
|
36
|
+
return (options?.client ?? this._client).post({
|
|
37
|
+
url: '/app/init',
|
|
38
|
+
...options
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Write a log entry to the server logs
|
|
43
|
+
*/
|
|
44
|
+
log(options) {
|
|
45
|
+
return (options?.client ?? this._client).post({
|
|
46
|
+
url: '/log',
|
|
47
|
+
...options,
|
|
48
|
+
headers: {
|
|
49
|
+
'Content-Type': 'application/json',
|
|
50
|
+
...options?.headers
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* List all modes
|
|
56
|
+
*/
|
|
57
|
+
modes(options) {
|
|
58
|
+
return (options?.client ?? this._client).get({
|
|
59
|
+
url: '/mode',
|
|
60
|
+
...options
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class Config extends _HeyApiClient {
|
|
65
|
+
/**
|
|
66
|
+
* Get config info
|
|
67
|
+
*/
|
|
68
|
+
get(options) {
|
|
69
|
+
return (options?.client ?? this._client).get({
|
|
70
|
+
url: '/config',
|
|
71
|
+
...options
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* List all providers
|
|
76
|
+
*/
|
|
77
|
+
providers(options) {
|
|
78
|
+
return (options?.client ?? this._client).get({
|
|
79
|
+
url: '/config/providers',
|
|
80
|
+
...options
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
class Session extends _HeyApiClient {
|
|
85
|
+
/**
|
|
86
|
+
* List all sessions
|
|
87
|
+
*/
|
|
88
|
+
list(options) {
|
|
89
|
+
return (options?.client ?? this._client).get({
|
|
90
|
+
url: '/session',
|
|
91
|
+
...options
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a new session
|
|
96
|
+
*/
|
|
97
|
+
create(options) {
|
|
98
|
+
return (options?.client ?? this._client).post({
|
|
99
|
+
url: '/session',
|
|
100
|
+
...options
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Delete a session and all its data
|
|
105
|
+
*/
|
|
106
|
+
delete(options) {
|
|
107
|
+
return (options.client ?? this._client).delete({
|
|
108
|
+
url: '/session/{id}',
|
|
109
|
+
...options
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Analyze the app and create an AGENTS.md file
|
|
114
|
+
*/
|
|
115
|
+
init(options) {
|
|
116
|
+
return (options.client ?? this._client).post({
|
|
117
|
+
url: '/session/{id}/init',
|
|
118
|
+
...options,
|
|
119
|
+
headers: {
|
|
120
|
+
'Content-Type': 'application/json',
|
|
121
|
+
...options.headers
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Abort a session
|
|
127
|
+
*/
|
|
128
|
+
abort(options) {
|
|
129
|
+
return (options.client ?? this._client).post({
|
|
130
|
+
url: '/session/{id}/abort',
|
|
131
|
+
...options
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Unshare the session
|
|
136
|
+
*/
|
|
137
|
+
unshare(options) {
|
|
138
|
+
return (options.client ?? this._client).delete({
|
|
139
|
+
url: '/session/{id}/share',
|
|
140
|
+
...options
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Share a session
|
|
145
|
+
*/
|
|
146
|
+
share(options) {
|
|
147
|
+
return (options.client ?? this._client).post({
|
|
148
|
+
url: '/session/{id}/share',
|
|
149
|
+
...options
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Summarize the session
|
|
154
|
+
*/
|
|
155
|
+
summarize(options) {
|
|
156
|
+
return (options.client ?? this._client).post({
|
|
157
|
+
url: '/session/{id}/summarize',
|
|
158
|
+
...options,
|
|
159
|
+
headers: {
|
|
160
|
+
'Content-Type': 'application/json',
|
|
161
|
+
...options.headers
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* List messages for a session
|
|
167
|
+
*/
|
|
168
|
+
messages(options) {
|
|
169
|
+
return (options.client ?? this._client).get({
|
|
170
|
+
url: '/session/{id}/message',
|
|
171
|
+
...options
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Create and send a new message to a session
|
|
176
|
+
*/
|
|
177
|
+
chat(options) {
|
|
178
|
+
return (options.client ?? this._client).post({
|
|
179
|
+
url: '/session/{id}/message',
|
|
180
|
+
...options,
|
|
181
|
+
headers: {
|
|
182
|
+
'Content-Type': 'application/json',
|
|
183
|
+
...options.headers
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Revert a message
|
|
189
|
+
*/
|
|
190
|
+
revert(options) {
|
|
191
|
+
return (options.client ?? this._client).post({
|
|
192
|
+
url: '/session/{id}/revert',
|
|
193
|
+
...options,
|
|
194
|
+
headers: {
|
|
195
|
+
'Content-Type': 'application/json',
|
|
196
|
+
...options.headers
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Restore all reverted messages
|
|
202
|
+
*/
|
|
203
|
+
unrevert(options) {
|
|
204
|
+
return (options.client ?? this._client).post({
|
|
205
|
+
url: '/session/{id}/unrevert',
|
|
206
|
+
...options
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
class Find extends _HeyApiClient {
|
|
211
|
+
/**
|
|
212
|
+
* Find text in files
|
|
213
|
+
*/
|
|
214
|
+
text(options) {
|
|
215
|
+
return (options.client ?? this._client).get({
|
|
216
|
+
url: '/find',
|
|
217
|
+
...options
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Find files
|
|
222
|
+
*/
|
|
223
|
+
files(options) {
|
|
224
|
+
return (options.client ?? this._client).get({
|
|
225
|
+
url: '/find/file',
|
|
226
|
+
...options
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Find workspace symbols
|
|
231
|
+
*/
|
|
232
|
+
symbols(options) {
|
|
233
|
+
return (options.client ?? this._client).get({
|
|
234
|
+
url: '/find/symbol',
|
|
235
|
+
...options
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
class File extends _HeyApiClient {
|
|
240
|
+
/**
|
|
241
|
+
* Read a file
|
|
242
|
+
*/
|
|
243
|
+
read(options) {
|
|
244
|
+
return (options.client ?? this._client).get({
|
|
245
|
+
url: '/file',
|
|
246
|
+
...options
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Get file status
|
|
251
|
+
*/
|
|
252
|
+
status(options) {
|
|
253
|
+
return (options?.client ?? this._client).get({
|
|
254
|
+
url: '/file/status',
|
|
255
|
+
...options
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
class Tui extends _HeyApiClient {
|
|
260
|
+
/**
|
|
261
|
+
* Append prompt to the TUI
|
|
262
|
+
*/
|
|
263
|
+
appendPrompt(options) {
|
|
264
|
+
return (options?.client ?? this._client).post({
|
|
265
|
+
url: '/tui/append-prompt',
|
|
266
|
+
...options,
|
|
267
|
+
headers: {
|
|
268
|
+
'Content-Type': 'application/json',
|
|
269
|
+
...options?.headers
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Open the help dialog
|
|
275
|
+
*/
|
|
276
|
+
openHelp(options) {
|
|
277
|
+
return (options?.client ?? this._client).post({
|
|
278
|
+
url: '/tui/open-help',
|
|
279
|
+
...options
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
export class OpencodeClient extends _HeyApiClient {
|
|
284
|
+
event = new Event({ client: this._client });
|
|
285
|
+
app = new App({ client: this._client });
|
|
286
|
+
config = new Config({ client: this._client });
|
|
287
|
+
session = new Session({ client: this._client });
|
|
288
|
+
find = new Find({ client: this._client });
|
|
289
|
+
file = new File({ client: this._client });
|
|
290
|
+
tui = new Tui({ client: this._client });
|
|
291
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@opencode-ai/sdk",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"version": "0.0.1",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"typescript": "5.8.2",
|
|
14
|
+
"@hey-api/openapi-ts": "0.80.1",
|
|
15
|
+
"@tsconfig/node22": "22.0.2"
|
|
16
|
+
}
|
|
17
|
+
}
|