@opencode-ai/sdk 0.4.45 → 0.5.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/sdk.gen.d.ts +8 -1
- package/dist/gen/sdk.gen.js +16 -0
- package/dist/gen/types.gen.d.ts +127 -77
- package/dist/index.d.ts +8 -0
- package/dist/index.js +15 -0
- package/package.json +1 -1
package/dist/gen/sdk.gen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as ClientOptions, TDataShape, Client } from "./client/index.js";
|
|
2
|
-
import type { EventSubscribeData, EventSubscribeResponses, AppGetData, AppGetResponses, AppInitData, AppInitResponses, ConfigGetData, ConfigGetResponses, SessionListData, SessionListResponses, SessionCreateData, SessionCreateResponses, SessionCreateErrors, SessionDeleteData, SessionDeleteResponses, SessionGetData, SessionGetResponses, SessionUpdateData, SessionUpdateResponses, SessionInitData, SessionInitResponses, SessionAbortData, SessionAbortResponses, SessionUnshareData, SessionUnshareResponses, SessionShareData, SessionShareResponses, SessionSummarizeData, SessionSummarizeResponses, SessionMessagesData, SessionMessagesResponses, SessionChatData, SessionChatResponses, SessionMessageData, SessionMessageResponses, SessionShellData, SessionShellResponses, SessionRevertData, SessionRevertResponses, SessionUnrevertData, SessionUnrevertResponses, PostSessionByIdPermissionsByPermissionIdData, PostSessionByIdPermissionsByPermissionIdResponses, ConfigProvidersData, ConfigProvidersResponses, FindTextData, FindTextResponses, FindFilesData, FindFilesResponses, FindSymbolsData, FindSymbolsResponses, FileReadData, FileReadResponses, FileStatusData, FileStatusResponses, AppLogData, AppLogResponses, AppAgentsData, AppAgentsResponses, TuiAppendPromptData, TuiAppendPromptResponses, TuiOpenHelpData, TuiOpenHelpResponses, TuiOpenSessionsData, TuiOpenSessionsResponses, TuiOpenThemesData, TuiOpenThemesResponses, TuiOpenModelsData, TuiOpenModelsResponses, TuiSubmitPromptData, TuiSubmitPromptResponses, TuiClearPromptData, TuiClearPromptResponses, TuiExecuteCommandData, TuiExecuteCommandResponses } from "./types.gen.js";
|
|
2
|
+
import type { EventSubscribeData, EventSubscribeResponses, AppGetData, AppGetResponses, AppInitData, AppInitResponses, ConfigGetData, ConfigGetResponses, SessionListData, SessionListResponses, SessionCreateData, SessionCreateResponses, SessionCreateErrors, SessionDeleteData, SessionDeleteResponses, SessionGetData, SessionGetResponses, SessionUpdateData, SessionUpdateResponses, SessionInitData, SessionInitResponses, SessionAbortData, SessionAbortResponses, SessionUnshareData, SessionUnshareResponses, SessionShareData, SessionShareResponses, SessionSummarizeData, SessionSummarizeResponses, SessionMessagesData, SessionMessagesResponses, SessionChatData, SessionChatResponses, SessionMessageData, SessionMessageResponses, SessionShellData, SessionShellResponses, SessionRevertData, SessionRevertResponses, SessionUnrevertData, SessionUnrevertResponses, PostSessionByIdPermissionsByPermissionIdData, PostSessionByIdPermissionsByPermissionIdResponses, ConfigProvidersData, ConfigProvidersResponses, FindTextData, FindTextResponses, FindFilesData, FindFilesResponses, FindSymbolsData, FindSymbolsResponses, FileReadData, FileReadResponses, FileStatusData, FileStatusResponses, AppLogData, AppLogResponses, AppAgentsData, AppAgentsResponses, TuiAppendPromptData, TuiAppendPromptResponses, TuiOpenHelpData, TuiOpenHelpResponses, TuiOpenSessionsData, TuiOpenSessionsResponses, TuiOpenThemesData, TuiOpenThemesResponses, TuiOpenModelsData, TuiOpenModelsResponses, TuiSubmitPromptData, TuiSubmitPromptResponses, TuiClearPromptData, TuiClearPromptResponses, TuiExecuteCommandData, TuiExecuteCommandResponses, AuthSetData, AuthSetResponses, AuthSetErrors } from "./types.gen.js";
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -177,6 +177,12 @@ declare class Tui extends _HeyApiClient {
|
|
|
177
177
|
*/
|
|
178
178
|
executeCommand<ThrowOnError extends boolean = false>(options?: Options<TuiExecuteCommandData, ThrowOnError>): import("./client/types.js").RequestResult<TuiExecuteCommandResponses, unknown, ThrowOnError, "fields">;
|
|
179
179
|
}
|
|
180
|
+
declare class Auth extends _HeyApiClient {
|
|
181
|
+
/**
|
|
182
|
+
* Set authentication credentials
|
|
183
|
+
*/
|
|
184
|
+
set<ThrowOnError extends boolean = false>(options: Options<AuthSetData, ThrowOnError>): import("./client/types.js").RequestResult<AuthSetResponses, AuthSetErrors, ThrowOnError, "fields">;
|
|
185
|
+
}
|
|
180
186
|
export declare class OpencodeClient extends _HeyApiClient {
|
|
181
187
|
/**
|
|
182
188
|
* Respond to a permission request
|
|
@@ -189,5 +195,6 @@ export declare class OpencodeClient extends _HeyApiClient {
|
|
|
189
195
|
find: Find;
|
|
190
196
|
file: File;
|
|
191
197
|
tui: Tui;
|
|
198
|
+
auth: Auth;
|
|
192
199
|
}
|
|
193
200
|
export {};
|
package/dist/gen/sdk.gen.js
CHANGED
|
@@ -382,6 +382,21 @@ class Tui extends _HeyApiClient {
|
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
+
class Auth extends _HeyApiClient {
|
|
386
|
+
/**
|
|
387
|
+
* Set authentication credentials
|
|
388
|
+
*/
|
|
389
|
+
set(options) {
|
|
390
|
+
return (options.client ?? this._client).put({
|
|
391
|
+
url: "/auth/{id}",
|
|
392
|
+
...options,
|
|
393
|
+
headers: {
|
|
394
|
+
"Content-Type": "application/json",
|
|
395
|
+
...options.headers,
|
|
396
|
+
},
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
385
400
|
export class OpencodeClient extends _HeyApiClient {
|
|
386
401
|
/**
|
|
387
402
|
* Respond to a permission request
|
|
@@ -403,4 +418,5 @@ export class OpencodeClient extends _HeyApiClient {
|
|
|
403
418
|
find = new Find({ client: this._client });
|
|
404
419
|
file = new File({ client: this._client });
|
|
405
420
|
tui = new Tui({ client: this._client });
|
|
421
|
+
auth = new Auth({ client: this._client });
|
|
406
422
|
}
|
package/dist/gen/types.gen.d.ts
CHANGED
|
@@ -13,14 +13,12 @@ export type Event = ({
|
|
|
13
13
|
} & EventMessagePartRemoved) | ({
|
|
14
14
|
type: "storage.write";
|
|
15
15
|
} & EventStorageWrite) | ({
|
|
16
|
-
type: "file.edited";
|
|
17
|
-
} & EventFileEdited) | ({
|
|
18
|
-
type: "server.connected";
|
|
19
|
-
} & EventServerConnected) | ({
|
|
20
16
|
type: "permission.updated";
|
|
21
17
|
} & EventPermissionUpdated) | ({
|
|
22
18
|
type: "permission.replied";
|
|
23
19
|
} & EventPermissionReplied) | ({
|
|
20
|
+
type: "file.edited";
|
|
21
|
+
} & EventFileEdited) | ({
|
|
24
22
|
type: "session.updated";
|
|
25
23
|
} & EventSessionUpdated) | ({
|
|
26
24
|
type: "session.deleted";
|
|
@@ -29,25 +27,27 @@ export type Event = ({
|
|
|
29
27
|
} & EventSessionIdle) | ({
|
|
30
28
|
type: "session.error";
|
|
31
29
|
} & EventSessionError) | ({
|
|
30
|
+
type: "server.connected";
|
|
31
|
+
} & EventServerConnected) | ({
|
|
32
32
|
type: "file.watcher.updated";
|
|
33
33
|
} & EventFileWatcherUpdated) | ({
|
|
34
34
|
type: "ide.installed";
|
|
35
35
|
} & EventIdeInstalled);
|
|
36
36
|
export type EventInstallationUpdated = {
|
|
37
|
-
type:
|
|
37
|
+
type: "installation.updated";
|
|
38
38
|
properties: {
|
|
39
39
|
version: string;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
export type EventLspClientDiagnostics = {
|
|
43
|
-
type:
|
|
43
|
+
type: "lsp.client.diagnostics";
|
|
44
44
|
properties: {
|
|
45
45
|
serverID: string;
|
|
46
46
|
path: string;
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
export type EventMessageUpdated = {
|
|
50
|
-
type:
|
|
50
|
+
type: "message.updated";
|
|
51
51
|
properties: {
|
|
52
52
|
info: Message;
|
|
53
53
|
};
|
|
@@ -60,7 +60,7 @@ export type Message = ({
|
|
|
60
60
|
export type UserMessage = {
|
|
61
61
|
id: string;
|
|
62
62
|
sessionID: string;
|
|
63
|
-
role:
|
|
63
|
+
role: "user";
|
|
64
64
|
time: {
|
|
65
65
|
created: number;
|
|
66
66
|
};
|
|
@@ -68,7 +68,7 @@ export type UserMessage = {
|
|
|
68
68
|
export type AssistantMessage = {
|
|
69
69
|
id: string;
|
|
70
70
|
sessionID: string;
|
|
71
|
-
role:
|
|
71
|
+
role: "assistant";
|
|
72
72
|
time: {
|
|
73
73
|
created: number;
|
|
74
74
|
completed?: number;
|
|
@@ -103,39 +103,39 @@ export type AssistantMessage = {
|
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
105
|
export type ProviderAuthError = {
|
|
106
|
-
name:
|
|
106
|
+
name: "ProviderAuthError";
|
|
107
107
|
data: {
|
|
108
108
|
providerID: string;
|
|
109
109
|
message: string;
|
|
110
110
|
};
|
|
111
111
|
};
|
|
112
112
|
export type UnknownError = {
|
|
113
|
-
name:
|
|
113
|
+
name: "UnknownError";
|
|
114
114
|
data: {
|
|
115
115
|
message: string;
|
|
116
116
|
};
|
|
117
117
|
};
|
|
118
118
|
export type MessageOutputLengthError = {
|
|
119
|
-
name:
|
|
119
|
+
name: "MessageOutputLengthError";
|
|
120
120
|
data: {
|
|
121
121
|
[key: string]: unknown;
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
export type MessageAbortedError = {
|
|
125
|
-
name:
|
|
125
|
+
name: "MessageAbortedError";
|
|
126
126
|
data: {
|
|
127
127
|
[key: string]: unknown;
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
130
|
export type EventMessageRemoved = {
|
|
131
|
-
type:
|
|
131
|
+
type: "message.removed";
|
|
132
132
|
properties: {
|
|
133
133
|
sessionID: string;
|
|
134
134
|
messageID: string;
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
137
|
export type EventMessagePartUpdated = {
|
|
138
|
-
type:
|
|
138
|
+
type: "message.part.updated";
|
|
139
139
|
properties: {
|
|
140
140
|
part: Part;
|
|
141
141
|
};
|
|
@@ -163,7 +163,7 @@ export type TextPart = {
|
|
|
163
163
|
id: string;
|
|
164
164
|
sessionID: string;
|
|
165
165
|
messageID: string;
|
|
166
|
-
type:
|
|
166
|
+
type: "text";
|
|
167
167
|
text: string;
|
|
168
168
|
synthetic?: boolean;
|
|
169
169
|
time?: {
|
|
@@ -175,7 +175,7 @@ export type ReasoningPart = {
|
|
|
175
175
|
id: string;
|
|
176
176
|
sessionID: string;
|
|
177
177
|
messageID: string;
|
|
178
|
-
type:
|
|
178
|
+
type: "reasoning";
|
|
179
179
|
text: string;
|
|
180
180
|
metadata?: {
|
|
181
181
|
[key: string]: unknown;
|
|
@@ -189,7 +189,7 @@ export type FilePart = {
|
|
|
189
189
|
id: string;
|
|
190
190
|
sessionID: string;
|
|
191
191
|
messageID: string;
|
|
192
|
-
type:
|
|
192
|
+
type: "file";
|
|
193
193
|
mime: string;
|
|
194
194
|
filename?: string;
|
|
195
195
|
url: string;
|
|
@@ -202,7 +202,7 @@ export type FilePartSource = ({
|
|
|
202
202
|
} & SymbolSource);
|
|
203
203
|
export type FileSource = {
|
|
204
204
|
text: FilePartSourceText;
|
|
205
|
-
type:
|
|
205
|
+
type: "file";
|
|
206
206
|
path: string;
|
|
207
207
|
};
|
|
208
208
|
export type FilePartSourceText = {
|
|
@@ -212,7 +212,7 @@ export type FilePartSourceText = {
|
|
|
212
212
|
};
|
|
213
213
|
export type SymbolSource = {
|
|
214
214
|
text: FilePartSourceText;
|
|
215
|
-
type:
|
|
215
|
+
type: "symbol";
|
|
216
216
|
path: string;
|
|
217
217
|
range: Range;
|
|
218
218
|
name: string;
|
|
@@ -232,7 +232,7 @@ export type ToolPart = {
|
|
|
232
232
|
id: string;
|
|
233
233
|
sessionID: string;
|
|
234
234
|
messageID: string;
|
|
235
|
-
type:
|
|
235
|
+
type: "tool";
|
|
236
236
|
callID: string;
|
|
237
237
|
tool: string;
|
|
238
238
|
state: ToolState;
|
|
@@ -247,10 +247,10 @@ export type ToolState = ({
|
|
|
247
247
|
status: "error";
|
|
248
248
|
} & ToolStateError);
|
|
249
249
|
export type ToolStatePending = {
|
|
250
|
-
status:
|
|
250
|
+
status: "pending";
|
|
251
251
|
};
|
|
252
252
|
export type ToolStateRunning = {
|
|
253
|
-
status:
|
|
253
|
+
status: "running";
|
|
254
254
|
input?: unknown;
|
|
255
255
|
title?: string;
|
|
256
256
|
metadata?: {
|
|
@@ -261,7 +261,7 @@ export type ToolStateRunning = {
|
|
|
261
261
|
};
|
|
262
262
|
};
|
|
263
263
|
export type ToolStateCompleted = {
|
|
264
|
-
status:
|
|
264
|
+
status: "completed";
|
|
265
265
|
input: {
|
|
266
266
|
[key: string]: unknown;
|
|
267
267
|
};
|
|
@@ -276,7 +276,7 @@ export type ToolStateCompleted = {
|
|
|
276
276
|
};
|
|
277
277
|
};
|
|
278
278
|
export type ToolStateError = {
|
|
279
|
-
status:
|
|
279
|
+
status: "error";
|
|
280
280
|
input: {
|
|
281
281
|
[key: string]: unknown;
|
|
282
282
|
};
|
|
@@ -290,13 +290,13 @@ export type StepStartPart = {
|
|
|
290
290
|
id: string;
|
|
291
291
|
sessionID: string;
|
|
292
292
|
messageID: string;
|
|
293
|
-
type:
|
|
293
|
+
type: "step-start";
|
|
294
294
|
};
|
|
295
295
|
export type StepFinishPart = {
|
|
296
296
|
id: string;
|
|
297
297
|
sessionID: string;
|
|
298
298
|
messageID: string;
|
|
299
|
-
type:
|
|
299
|
+
type: "step-finish";
|
|
300
300
|
cost: number;
|
|
301
301
|
tokens: {
|
|
302
302
|
input: number;
|
|
@@ -312,14 +312,14 @@ export type SnapshotPart = {
|
|
|
312
312
|
id: string;
|
|
313
313
|
sessionID: string;
|
|
314
314
|
messageID: string;
|
|
315
|
-
type:
|
|
315
|
+
type: "snapshot";
|
|
316
316
|
snapshot: string;
|
|
317
317
|
};
|
|
318
318
|
export type PatchPart = {
|
|
319
319
|
id: string;
|
|
320
320
|
sessionID: string;
|
|
321
321
|
messageID: string;
|
|
322
|
-
type:
|
|
322
|
+
type: "patch";
|
|
323
323
|
hash: string;
|
|
324
324
|
files: Array<string>;
|
|
325
325
|
};
|
|
@@ -327,7 +327,7 @@ export type AgentPart = {
|
|
|
327
327
|
id: string;
|
|
328
328
|
sessionID: string;
|
|
329
329
|
messageID: string;
|
|
330
|
-
type:
|
|
330
|
+
type: "agent";
|
|
331
331
|
name: string;
|
|
332
332
|
source?: {
|
|
333
333
|
value: string;
|
|
@@ -336,7 +336,7 @@ export type AgentPart = {
|
|
|
336
336
|
};
|
|
337
337
|
};
|
|
338
338
|
export type EventMessagePartRemoved = {
|
|
339
|
-
type:
|
|
339
|
+
type: "message.part.removed";
|
|
340
340
|
properties: {
|
|
341
341
|
sessionID: string;
|
|
342
342
|
messageID: string;
|
|
@@ -344,26 +344,14 @@ export type EventMessagePartRemoved = {
|
|
|
344
344
|
};
|
|
345
345
|
};
|
|
346
346
|
export type EventStorageWrite = {
|
|
347
|
-
type:
|
|
347
|
+
type: "storage.write";
|
|
348
348
|
properties: {
|
|
349
349
|
key: string;
|
|
350
350
|
content?: unknown;
|
|
351
351
|
};
|
|
352
352
|
};
|
|
353
|
-
export type EventFileEdited = {
|
|
354
|
-
type: string;
|
|
355
|
-
properties: {
|
|
356
|
-
file: string;
|
|
357
|
-
};
|
|
358
|
-
};
|
|
359
|
-
export type EventServerConnected = {
|
|
360
|
-
type: string;
|
|
361
|
-
properties: {
|
|
362
|
-
[key: string]: unknown;
|
|
363
|
-
};
|
|
364
|
-
};
|
|
365
353
|
export type EventPermissionUpdated = {
|
|
366
|
-
type:
|
|
354
|
+
type: "permission.updated";
|
|
367
355
|
properties: Permission;
|
|
368
356
|
};
|
|
369
357
|
export type Permission = {
|
|
@@ -382,15 +370,21 @@ export type Permission = {
|
|
|
382
370
|
};
|
|
383
371
|
};
|
|
384
372
|
export type EventPermissionReplied = {
|
|
385
|
-
type:
|
|
373
|
+
type: "permission.replied";
|
|
386
374
|
properties: {
|
|
387
375
|
sessionID: string;
|
|
388
376
|
permissionID: string;
|
|
389
377
|
response: string;
|
|
390
378
|
};
|
|
391
379
|
};
|
|
380
|
+
export type EventFileEdited = {
|
|
381
|
+
type: "file.edited";
|
|
382
|
+
properties: {
|
|
383
|
+
file: string;
|
|
384
|
+
};
|
|
385
|
+
};
|
|
392
386
|
export type EventSessionUpdated = {
|
|
393
|
-
type:
|
|
387
|
+
type: "session.updated";
|
|
394
388
|
properties: {
|
|
395
389
|
info: Session;
|
|
396
390
|
};
|
|
@@ -415,19 +409,19 @@ export type Session = {
|
|
|
415
409
|
};
|
|
416
410
|
};
|
|
417
411
|
export type EventSessionDeleted = {
|
|
418
|
-
type:
|
|
412
|
+
type: "session.deleted";
|
|
419
413
|
properties: {
|
|
420
414
|
info: Session;
|
|
421
415
|
};
|
|
422
416
|
};
|
|
423
417
|
export type EventSessionIdle = {
|
|
424
|
-
type:
|
|
418
|
+
type: "session.idle";
|
|
425
419
|
properties: {
|
|
426
420
|
sessionID: string;
|
|
427
421
|
};
|
|
428
422
|
};
|
|
429
423
|
export type EventSessionError = {
|
|
430
|
-
type:
|
|
424
|
+
type: "session.error";
|
|
431
425
|
properties: {
|
|
432
426
|
sessionID?: string;
|
|
433
427
|
error?: ({
|
|
@@ -441,15 +435,21 @@ export type EventSessionError = {
|
|
|
441
435
|
} & MessageAbortedError);
|
|
442
436
|
};
|
|
443
437
|
};
|
|
438
|
+
export type EventServerConnected = {
|
|
439
|
+
type: "server.connected";
|
|
440
|
+
properties: {
|
|
441
|
+
[key: string]: unknown;
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
444
|
export type EventFileWatcherUpdated = {
|
|
445
|
-
type:
|
|
445
|
+
type: "file.watcher.updated";
|
|
446
446
|
properties: {
|
|
447
447
|
file: string;
|
|
448
|
-
event:
|
|
448
|
+
event: "rename" | "change";
|
|
449
449
|
};
|
|
450
450
|
};
|
|
451
451
|
export type EventIdeInstalled = {
|
|
452
|
-
type:
|
|
452
|
+
type: "ide.installed";
|
|
453
453
|
properties: {
|
|
454
454
|
ide: string;
|
|
455
455
|
};
|
|
@@ -477,6 +477,9 @@ export type Config = {
|
|
|
477
477
|
* Theme name to use for the interface
|
|
478
478
|
*/
|
|
479
479
|
theme?: string;
|
|
480
|
+
/**
|
|
481
|
+
* Custom keybind configurations
|
|
482
|
+
*/
|
|
480
483
|
keybinds?: KeybindsConfig;
|
|
481
484
|
plugin?: Array<string>;
|
|
482
485
|
snapshot?: boolean;
|
|
@@ -588,7 +591,7 @@ export type Config = {
|
|
|
588
591
|
};
|
|
589
592
|
lsp?: {
|
|
590
593
|
[key: string]: {
|
|
591
|
-
disabled:
|
|
594
|
+
disabled: true;
|
|
592
595
|
} | {
|
|
593
596
|
command: Array<string>;
|
|
594
597
|
extensions?: Array<string>;
|
|
@@ -605,13 +608,16 @@ export type Config = {
|
|
|
605
608
|
* Additional instruction files or patterns to include
|
|
606
609
|
*/
|
|
607
610
|
instructions?: Array<string>;
|
|
611
|
+
/**
|
|
612
|
+
* @deprecated Always uses stretch layout.
|
|
613
|
+
*/
|
|
608
614
|
layout?: LayoutConfig;
|
|
609
615
|
permission?: {
|
|
610
|
-
edit?:
|
|
611
|
-
bash?:
|
|
612
|
-
[key: string]:
|
|
616
|
+
edit?: "ask" | "allow" | "deny";
|
|
617
|
+
bash?: ("ask" | "allow" | "deny") | {
|
|
618
|
+
[key: string]: "ask" | "allow" | "deny";
|
|
613
619
|
};
|
|
614
|
-
webfetch?:
|
|
620
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
615
621
|
};
|
|
616
622
|
experimental?: {
|
|
617
623
|
hook?: {
|
|
@@ -811,22 +817,22 @@ export type AgentConfig = {
|
|
|
811
817
|
* Description of when to use the agent
|
|
812
818
|
*/
|
|
813
819
|
description?: string;
|
|
814
|
-
mode?:
|
|
820
|
+
mode?: "subagent" | "primary" | "all";
|
|
815
821
|
permission?: {
|
|
816
|
-
edit?:
|
|
817
|
-
bash?:
|
|
818
|
-
[key: string]:
|
|
822
|
+
edit?: "ask" | "allow" | "deny";
|
|
823
|
+
bash?: ("ask" | "allow" | "deny") | {
|
|
824
|
+
[key: string]: "ask" | "allow" | "deny";
|
|
819
825
|
};
|
|
820
|
-
webfetch?:
|
|
826
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
821
827
|
};
|
|
822
828
|
[key: string]: unknown | string | number | {
|
|
823
829
|
[key: string]: boolean;
|
|
824
|
-
} | boolean |
|
|
825
|
-
edit?:
|
|
826
|
-
bash?:
|
|
827
|
-
[key: string]:
|
|
830
|
+
} | boolean | ("subagent" | "primary" | "all") | {
|
|
831
|
+
edit?: "ask" | "allow" | "deny";
|
|
832
|
+
bash?: ("ask" | "allow" | "deny") | {
|
|
833
|
+
[key: string]: "ask" | "allow" | "deny";
|
|
828
834
|
};
|
|
829
|
-
webfetch?:
|
|
835
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
830
836
|
} | undefined;
|
|
831
837
|
};
|
|
832
838
|
export type Provider = {
|
|
@@ -865,7 +871,7 @@ export type McpLocalConfig = {
|
|
|
865
871
|
/**
|
|
866
872
|
* Type of MCP server connection
|
|
867
873
|
*/
|
|
868
|
-
type:
|
|
874
|
+
type: "local";
|
|
869
875
|
/**
|
|
870
876
|
* Command and arguments to run the MCP server
|
|
871
877
|
*/
|
|
@@ -885,7 +891,7 @@ export type McpRemoteConfig = {
|
|
|
885
891
|
/**
|
|
886
892
|
* Type of MCP server connection
|
|
887
893
|
*/
|
|
888
|
-
type:
|
|
894
|
+
type: "remote";
|
|
889
895
|
/**
|
|
890
896
|
* URL of the remote MCP server
|
|
891
897
|
*/
|
|
@@ -909,7 +915,7 @@ export type _Error = {
|
|
|
909
915
|
};
|
|
910
916
|
export type TextPartInput = {
|
|
911
917
|
id?: string;
|
|
912
|
-
type:
|
|
918
|
+
type: "text";
|
|
913
919
|
text: string;
|
|
914
920
|
synthetic?: boolean;
|
|
915
921
|
time?: {
|
|
@@ -919,7 +925,7 @@ export type TextPartInput = {
|
|
|
919
925
|
};
|
|
920
926
|
export type FilePartInput = {
|
|
921
927
|
id?: string;
|
|
922
|
-
type:
|
|
928
|
+
type: "file";
|
|
923
929
|
mime: string;
|
|
924
930
|
filename?: string;
|
|
925
931
|
url: string;
|
|
@@ -927,7 +933,7 @@ export type FilePartInput = {
|
|
|
927
933
|
};
|
|
928
934
|
export type AgentPartInput = {
|
|
929
935
|
id?: string;
|
|
930
|
-
type:
|
|
936
|
+
type: "agent";
|
|
931
937
|
name: string;
|
|
932
938
|
source?: {
|
|
933
939
|
value: string;
|
|
@@ -952,15 +958,15 @@ export type File = {
|
|
|
952
958
|
export type Agent = {
|
|
953
959
|
name: string;
|
|
954
960
|
description?: string;
|
|
955
|
-
mode:
|
|
961
|
+
mode: "subagent" | "primary" | "all";
|
|
956
962
|
topP?: number;
|
|
957
963
|
temperature?: number;
|
|
958
964
|
permission: {
|
|
959
|
-
edit:
|
|
965
|
+
edit: "ask" | "allow" | "deny";
|
|
960
966
|
bash: {
|
|
961
|
-
[key: string]:
|
|
967
|
+
[key: string]: "ask" | "allow" | "deny";
|
|
962
968
|
};
|
|
963
|
-
webfetch?:
|
|
969
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
964
970
|
};
|
|
965
971
|
model?: {
|
|
966
972
|
modelID: string;
|
|
@@ -974,6 +980,28 @@ export type Agent = {
|
|
|
974
980
|
[key: string]: unknown;
|
|
975
981
|
};
|
|
976
982
|
};
|
|
983
|
+
export type Auth = ({
|
|
984
|
+
type: "oauth";
|
|
985
|
+
} & OAuth) | ({
|
|
986
|
+
type: "api";
|
|
987
|
+
} & ApiAuth) | ({
|
|
988
|
+
type: "wellknown";
|
|
989
|
+
} & WellKnownAuth);
|
|
990
|
+
export type OAuth = {
|
|
991
|
+
type: "oauth";
|
|
992
|
+
refresh: string;
|
|
993
|
+
access: string;
|
|
994
|
+
expires: number;
|
|
995
|
+
};
|
|
996
|
+
export type ApiAuth = {
|
|
997
|
+
type: "api";
|
|
998
|
+
key: string;
|
|
999
|
+
};
|
|
1000
|
+
export type WellKnownAuth = {
|
|
1001
|
+
type: "wellknown";
|
|
1002
|
+
key: string;
|
|
1003
|
+
token: string;
|
|
1004
|
+
};
|
|
977
1005
|
export type EventSubscribeData = {
|
|
978
1006
|
body?: never;
|
|
979
1007
|
path?: never;
|
|
@@ -1609,6 +1637,28 @@ export type TuiExecuteCommandResponses = {
|
|
|
1609
1637
|
200: boolean;
|
|
1610
1638
|
};
|
|
1611
1639
|
export type TuiExecuteCommandResponse = TuiExecuteCommandResponses[keyof TuiExecuteCommandResponses];
|
|
1640
|
+
export type AuthSetData = {
|
|
1641
|
+
body?: Auth;
|
|
1642
|
+
path: {
|
|
1643
|
+
id: string;
|
|
1644
|
+
};
|
|
1645
|
+
query?: never;
|
|
1646
|
+
url: "/auth/{id}";
|
|
1647
|
+
};
|
|
1648
|
+
export type AuthSetErrors = {
|
|
1649
|
+
/**
|
|
1650
|
+
* Bad request
|
|
1651
|
+
*/
|
|
1652
|
+
400: _Error;
|
|
1653
|
+
};
|
|
1654
|
+
export type AuthSetError = AuthSetErrors[keyof AuthSetErrors];
|
|
1655
|
+
export type AuthSetResponses = {
|
|
1656
|
+
/**
|
|
1657
|
+
* Successfully set authentication credentials
|
|
1658
|
+
*/
|
|
1659
|
+
200: boolean;
|
|
1660
|
+
};
|
|
1661
|
+
export type AuthSetResponse = AuthSetResponses[keyof AuthSetResponses];
|
|
1612
1662
|
export type ClientOptions = {
|
|
1613
1663
|
baseUrl: `${string}://${string}` | (string & {});
|
|
1614
1664
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,3 +2,11 @@ import { type Config } from "./gen/client/types.js";
|
|
|
2
2
|
import { OpencodeClient } from "./gen/sdk.gen.js";
|
|
3
3
|
export * from "./gen/types.gen.js";
|
|
4
4
|
export declare function createOpencodeClient(config?: Config): OpencodeClient;
|
|
5
|
+
export type ServerConfig = {
|
|
6
|
+
host?: string;
|
|
7
|
+
port?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function createOpencodeServer(config?: ServerConfig): Promise<{
|
|
10
|
+
url: string;
|
|
11
|
+
close(): void;
|
|
12
|
+
}>;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import { createClient } from "./gen/client/client.js";
|
|
2
2
|
import { OpencodeClient } from "./gen/sdk.gen.js";
|
|
3
3
|
export * from "./gen/types.gen.js";
|
|
4
|
+
import { spawn } from "child_process";
|
|
4
5
|
export function createOpencodeClient(config) {
|
|
5
6
|
const client = createClient(config);
|
|
6
7
|
return new OpencodeClient({ client });
|
|
7
8
|
}
|
|
9
|
+
export async function createOpencodeServer(config) {
|
|
10
|
+
config = Object.assign({
|
|
11
|
+
host: "127.0.0.1",
|
|
12
|
+
port: 4096,
|
|
13
|
+
}, config ?? {});
|
|
14
|
+
const proc = spawn(`opencode`, [`serve`, `--host=${config.host}`, `--port=${config.port}`]);
|
|
15
|
+
const url = `http://${config.host}:${config.port}`;
|
|
16
|
+
return {
|
|
17
|
+
url,
|
|
18
|
+
close() {
|
|
19
|
+
proc.kill();
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|