@opencode-ai/sdk 0.4.45 → 0.5.2
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 +17 -2
- package/dist/gen/sdk.gen.js +43 -1
- package/dist/gen/types.gen.d.ts +255 -138
- 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, SessionChildrenData, SessionChildrenResponses, 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, TuiShowToastData, TuiShowToastResponses, 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
|
|
@@ -74,6 +74,10 @@ declare class Session extends _HeyApiClient {
|
|
|
74
74
|
* Update session properties
|
|
75
75
|
*/
|
|
76
76
|
update<ThrowOnError extends boolean = false>(options: Options<SessionUpdateData, ThrowOnError>): import("./client/types.js").RequestResult<SessionUpdateResponses, unknown, ThrowOnError, "fields">;
|
|
77
|
+
/**
|
|
78
|
+
* Get a session's children
|
|
79
|
+
*/
|
|
80
|
+
children<ThrowOnError extends boolean = false>(options: Options<SessionChildrenData, ThrowOnError>): import("./client/types.js").RequestResult<SessionChildrenResponses, unknown, ThrowOnError, "fields">;
|
|
77
81
|
/**
|
|
78
82
|
* Analyze the app and create an AGENTS.md file
|
|
79
83
|
*/
|
|
@@ -173,9 +177,19 @@ declare class Tui extends _HeyApiClient {
|
|
|
173
177
|
*/
|
|
174
178
|
clearPrompt<ThrowOnError extends boolean = false>(options?: Options<TuiClearPromptData, ThrowOnError>): import("./client/types.js").RequestResult<TuiClearPromptResponses, unknown, ThrowOnError, "fields">;
|
|
175
179
|
/**
|
|
176
|
-
* Execute a TUI command (e.g.
|
|
180
|
+
* Execute a TUI command (e.g. agent_cycle)
|
|
177
181
|
*/
|
|
178
182
|
executeCommand<ThrowOnError extends boolean = false>(options?: Options<TuiExecuteCommandData, ThrowOnError>): import("./client/types.js").RequestResult<TuiExecuteCommandResponses, unknown, ThrowOnError, "fields">;
|
|
183
|
+
/**
|
|
184
|
+
* Show a toast notification in the TUI
|
|
185
|
+
*/
|
|
186
|
+
showToast<ThrowOnError extends boolean = false>(options?: Options<TuiShowToastData, ThrowOnError>): import("./client/types.js").RequestResult<TuiShowToastResponses, unknown, ThrowOnError, "fields">;
|
|
187
|
+
}
|
|
188
|
+
declare class Auth extends _HeyApiClient {
|
|
189
|
+
/**
|
|
190
|
+
* Set authentication credentials
|
|
191
|
+
*/
|
|
192
|
+
set<ThrowOnError extends boolean = false>(options: Options<AuthSetData, ThrowOnError>): import("./client/types.js").RequestResult<AuthSetResponses, AuthSetErrors, ThrowOnError, "fields">;
|
|
179
193
|
}
|
|
180
194
|
export declare class OpencodeClient extends _HeyApiClient {
|
|
181
195
|
/**
|
|
@@ -189,5 +203,6 @@ export declare class OpencodeClient extends _HeyApiClient {
|
|
|
189
203
|
find: Find;
|
|
190
204
|
file: File;
|
|
191
205
|
tui: Tui;
|
|
206
|
+
auth: Auth;
|
|
192
207
|
}
|
|
193
208
|
export {};
|
package/dist/gen/sdk.gen.js
CHANGED
|
@@ -98,6 +98,10 @@ class Session extends _HeyApiClient {
|
|
|
98
98
|
return (options?.client ?? this._client).post({
|
|
99
99
|
url: "/session",
|
|
100
100
|
...options,
|
|
101
|
+
headers: {
|
|
102
|
+
"Content-Type": "application/json",
|
|
103
|
+
...options?.headers,
|
|
104
|
+
},
|
|
101
105
|
});
|
|
102
106
|
}
|
|
103
107
|
/**
|
|
@@ -131,6 +135,15 @@ class Session extends _HeyApiClient {
|
|
|
131
135
|
},
|
|
132
136
|
});
|
|
133
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Get a session's children
|
|
140
|
+
*/
|
|
141
|
+
children(options) {
|
|
142
|
+
return (options.client ?? this._client).get({
|
|
143
|
+
url: "/session/{id}/children",
|
|
144
|
+
...options,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
134
147
|
/**
|
|
135
148
|
* Analyze the app and create an AGENTS.md file
|
|
136
149
|
*/
|
|
@@ -369,7 +382,7 @@ class Tui extends _HeyApiClient {
|
|
|
369
382
|
});
|
|
370
383
|
}
|
|
371
384
|
/**
|
|
372
|
-
* Execute a TUI command (e.g.
|
|
385
|
+
* Execute a TUI command (e.g. agent_cycle)
|
|
373
386
|
*/
|
|
374
387
|
executeCommand(options) {
|
|
375
388
|
return (options?.client ?? this._client).post({
|
|
@@ -381,6 +394,34 @@ class Tui extends _HeyApiClient {
|
|
|
381
394
|
},
|
|
382
395
|
});
|
|
383
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Show a toast notification in the TUI
|
|
399
|
+
*/
|
|
400
|
+
showToast(options) {
|
|
401
|
+
return (options?.client ?? this._client).post({
|
|
402
|
+
url: "/tui/show-toast",
|
|
403
|
+
...options,
|
|
404
|
+
headers: {
|
|
405
|
+
"Content-Type": "application/json",
|
|
406
|
+
...options?.headers,
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
class Auth extends _HeyApiClient {
|
|
412
|
+
/**
|
|
413
|
+
* Set authentication credentials
|
|
414
|
+
*/
|
|
415
|
+
set(options) {
|
|
416
|
+
return (options.client ?? this._client).put({
|
|
417
|
+
url: "/auth/{id}",
|
|
418
|
+
...options,
|
|
419
|
+
headers: {
|
|
420
|
+
"Content-Type": "application/json",
|
|
421
|
+
...options.headers,
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
}
|
|
384
425
|
}
|
|
385
426
|
export class OpencodeClient extends _HeyApiClient {
|
|
386
427
|
/**
|
|
@@ -403,4 +444,5 @@ export class OpencodeClient extends _HeyApiClient {
|
|
|
403
444
|
find = new Find({ client: this._client });
|
|
404
445
|
file = new File({ client: this._client });
|
|
405
446
|
tui = new Tui({ client: this._client });
|
|
447
|
+
auth = new Auth({ client: this._client });
|
|
406
448
|
}
|
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,11 +276,14 @@ 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
|
};
|
|
283
283
|
error: string;
|
|
284
|
+
metadata?: {
|
|
285
|
+
[key: string]: unknown;
|
|
286
|
+
};
|
|
284
287
|
time: {
|
|
285
288
|
start: number;
|
|
286
289
|
end: number;
|
|
@@ -290,13 +293,13 @@ export type StepStartPart = {
|
|
|
290
293
|
id: string;
|
|
291
294
|
sessionID: string;
|
|
292
295
|
messageID: string;
|
|
293
|
-
type:
|
|
296
|
+
type: "step-start";
|
|
294
297
|
};
|
|
295
298
|
export type StepFinishPart = {
|
|
296
299
|
id: string;
|
|
297
300
|
sessionID: string;
|
|
298
301
|
messageID: string;
|
|
299
|
-
type:
|
|
302
|
+
type: "step-finish";
|
|
300
303
|
cost: number;
|
|
301
304
|
tokens: {
|
|
302
305
|
input: number;
|
|
@@ -312,14 +315,14 @@ export type SnapshotPart = {
|
|
|
312
315
|
id: string;
|
|
313
316
|
sessionID: string;
|
|
314
317
|
messageID: string;
|
|
315
|
-
type:
|
|
318
|
+
type: "snapshot";
|
|
316
319
|
snapshot: string;
|
|
317
320
|
};
|
|
318
321
|
export type PatchPart = {
|
|
319
322
|
id: string;
|
|
320
323
|
sessionID: string;
|
|
321
324
|
messageID: string;
|
|
322
|
-
type:
|
|
325
|
+
type: "patch";
|
|
323
326
|
hash: string;
|
|
324
327
|
files: Array<string>;
|
|
325
328
|
};
|
|
@@ -327,7 +330,7 @@ export type AgentPart = {
|
|
|
327
330
|
id: string;
|
|
328
331
|
sessionID: string;
|
|
329
332
|
messageID: string;
|
|
330
|
-
type:
|
|
333
|
+
type: "agent";
|
|
331
334
|
name: string;
|
|
332
335
|
source?: {
|
|
333
336
|
value: string;
|
|
@@ -336,7 +339,7 @@ export type AgentPart = {
|
|
|
336
339
|
};
|
|
337
340
|
};
|
|
338
341
|
export type EventMessagePartRemoved = {
|
|
339
|
-
type:
|
|
342
|
+
type: "message.part.removed";
|
|
340
343
|
properties: {
|
|
341
344
|
sessionID: string;
|
|
342
345
|
messageID: string;
|
|
@@ -344,26 +347,14 @@ export type EventMessagePartRemoved = {
|
|
|
344
347
|
};
|
|
345
348
|
};
|
|
346
349
|
export type EventStorageWrite = {
|
|
347
|
-
type:
|
|
350
|
+
type: "storage.write";
|
|
348
351
|
properties: {
|
|
349
352
|
key: string;
|
|
350
353
|
content?: unknown;
|
|
351
354
|
};
|
|
352
355
|
};
|
|
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
356
|
export type EventPermissionUpdated = {
|
|
366
|
-
type:
|
|
357
|
+
type: "permission.updated";
|
|
367
358
|
properties: Permission;
|
|
368
359
|
};
|
|
369
360
|
export type Permission = {
|
|
@@ -382,15 +373,21 @@ export type Permission = {
|
|
|
382
373
|
};
|
|
383
374
|
};
|
|
384
375
|
export type EventPermissionReplied = {
|
|
385
|
-
type:
|
|
376
|
+
type: "permission.replied";
|
|
386
377
|
properties: {
|
|
387
378
|
sessionID: string;
|
|
388
379
|
permissionID: string;
|
|
389
380
|
response: string;
|
|
390
381
|
};
|
|
391
382
|
};
|
|
383
|
+
export type EventFileEdited = {
|
|
384
|
+
type: "file.edited";
|
|
385
|
+
properties: {
|
|
386
|
+
file: string;
|
|
387
|
+
};
|
|
388
|
+
};
|
|
392
389
|
export type EventSessionUpdated = {
|
|
393
|
-
type:
|
|
390
|
+
type: "session.updated";
|
|
394
391
|
properties: {
|
|
395
392
|
info: Session;
|
|
396
393
|
};
|
|
@@ -415,19 +412,19 @@ export type Session = {
|
|
|
415
412
|
};
|
|
416
413
|
};
|
|
417
414
|
export type EventSessionDeleted = {
|
|
418
|
-
type:
|
|
415
|
+
type: "session.deleted";
|
|
419
416
|
properties: {
|
|
420
417
|
info: Session;
|
|
421
418
|
};
|
|
422
419
|
};
|
|
423
420
|
export type EventSessionIdle = {
|
|
424
|
-
type:
|
|
421
|
+
type: "session.idle";
|
|
425
422
|
properties: {
|
|
426
423
|
sessionID: string;
|
|
427
424
|
};
|
|
428
425
|
};
|
|
429
426
|
export type EventSessionError = {
|
|
430
|
-
type:
|
|
427
|
+
type: "session.error";
|
|
431
428
|
properties: {
|
|
432
429
|
sessionID?: string;
|
|
433
430
|
error?: ({
|
|
@@ -441,15 +438,21 @@ export type EventSessionError = {
|
|
|
441
438
|
} & MessageAbortedError);
|
|
442
439
|
};
|
|
443
440
|
};
|
|
441
|
+
export type EventServerConnected = {
|
|
442
|
+
type: "server.connected";
|
|
443
|
+
properties: {
|
|
444
|
+
[key: string]: unknown;
|
|
445
|
+
};
|
|
446
|
+
};
|
|
444
447
|
export type EventFileWatcherUpdated = {
|
|
445
|
-
type:
|
|
448
|
+
type: "file.watcher.updated";
|
|
446
449
|
properties: {
|
|
447
450
|
file: string;
|
|
448
|
-
event:
|
|
451
|
+
event: "rename" | "change";
|
|
449
452
|
};
|
|
450
453
|
};
|
|
451
454
|
export type EventIdeInstalled = {
|
|
452
|
-
type:
|
|
455
|
+
type: "ide.installed";
|
|
453
456
|
properties: {
|
|
454
457
|
ide: string;
|
|
455
458
|
};
|
|
@@ -477,6 +480,9 @@ export type Config = {
|
|
|
477
480
|
* Theme name to use for the interface
|
|
478
481
|
*/
|
|
479
482
|
theme?: string;
|
|
483
|
+
/**
|
|
484
|
+
* Custom keybind configurations
|
|
485
|
+
*/
|
|
480
486
|
keybinds?: KeybindsConfig;
|
|
481
487
|
plugin?: Array<string>;
|
|
482
488
|
snapshot?: boolean;
|
|
@@ -588,7 +594,7 @@ export type Config = {
|
|
|
588
594
|
};
|
|
589
595
|
lsp?: {
|
|
590
596
|
[key: string]: {
|
|
591
|
-
disabled:
|
|
597
|
+
disabled: true;
|
|
592
598
|
} | {
|
|
593
599
|
command: Array<string>;
|
|
594
600
|
extensions?: Array<string>;
|
|
@@ -605,13 +611,16 @@ export type Config = {
|
|
|
605
611
|
* Additional instruction files or patterns to include
|
|
606
612
|
*/
|
|
607
613
|
instructions?: Array<string>;
|
|
614
|
+
/**
|
|
615
|
+
* @deprecated Always uses stretch layout.
|
|
616
|
+
*/
|
|
608
617
|
layout?: LayoutConfig;
|
|
609
618
|
permission?: {
|
|
610
|
-
edit?:
|
|
611
|
-
bash?:
|
|
612
|
-
[key: string]:
|
|
619
|
+
edit?: "ask" | "allow" | "deny";
|
|
620
|
+
bash?: ("ask" | "allow" | "deny") | {
|
|
621
|
+
[key: string]: "ask" | "allow" | "deny";
|
|
613
622
|
};
|
|
614
|
-
webfetch?:
|
|
623
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
615
624
|
};
|
|
616
625
|
experimental?: {
|
|
617
626
|
hook?: {
|
|
@@ -642,25 +651,29 @@ export type KeybindsConfig = {
|
|
|
642
651
|
*/
|
|
643
652
|
app_help: string;
|
|
644
653
|
/**
|
|
645
|
-
*
|
|
654
|
+
* Exit the application
|
|
646
655
|
*/
|
|
647
|
-
|
|
656
|
+
app_exit: string;
|
|
648
657
|
/**
|
|
649
|
-
*
|
|
658
|
+
* Open external editor
|
|
650
659
|
*/
|
|
651
|
-
|
|
660
|
+
editor_open: string;
|
|
652
661
|
/**
|
|
653
|
-
*
|
|
662
|
+
* List available themes
|
|
654
663
|
*/
|
|
655
|
-
|
|
664
|
+
theme_list: string;
|
|
656
665
|
/**
|
|
657
|
-
*
|
|
666
|
+
* Create/update AGENTS.md
|
|
658
667
|
*/
|
|
659
|
-
|
|
668
|
+
project_init: string;
|
|
660
669
|
/**
|
|
661
|
-
*
|
|
670
|
+
* Toggle tool details
|
|
662
671
|
*/
|
|
663
|
-
|
|
672
|
+
tool_details: string;
|
|
673
|
+
/**
|
|
674
|
+
* Toggle thinking blocks
|
|
675
|
+
*/
|
|
676
|
+
thinking_blocks: string;
|
|
664
677
|
/**
|
|
665
678
|
* Export session to editor
|
|
666
679
|
*/
|
|
@@ -690,41 +703,73 @@ export type KeybindsConfig = {
|
|
|
690
703
|
*/
|
|
691
704
|
session_compact: string;
|
|
692
705
|
/**
|
|
693
|
-
*
|
|
706
|
+
* Cycle to next child session
|
|
694
707
|
*/
|
|
695
|
-
|
|
708
|
+
session_child_cycle: string;
|
|
696
709
|
/**
|
|
697
|
-
*
|
|
710
|
+
* Cycle to previous child session
|
|
698
711
|
*/
|
|
699
|
-
|
|
712
|
+
session_child_cycle_reverse: string;
|
|
700
713
|
/**
|
|
701
|
-
*
|
|
714
|
+
* Scroll messages up by one page
|
|
702
715
|
*/
|
|
703
|
-
|
|
716
|
+
messages_page_up: string;
|
|
704
717
|
/**
|
|
705
|
-
*
|
|
718
|
+
* Scroll messages down by one page
|
|
706
719
|
*/
|
|
707
|
-
|
|
720
|
+
messages_page_down: string;
|
|
708
721
|
/**
|
|
709
|
-
*
|
|
722
|
+
* Scroll messages up by half page
|
|
710
723
|
*/
|
|
711
|
-
|
|
724
|
+
messages_half_page_up: string;
|
|
712
725
|
/**
|
|
713
|
-
*
|
|
726
|
+
* Scroll messages down by half page
|
|
714
727
|
*/
|
|
715
|
-
|
|
728
|
+
messages_half_page_down: string;
|
|
716
729
|
/**
|
|
717
|
-
*
|
|
730
|
+
* Navigate to first message
|
|
718
731
|
*/
|
|
719
|
-
|
|
732
|
+
messages_first: string;
|
|
720
733
|
/**
|
|
721
|
-
*
|
|
734
|
+
* Navigate to last message
|
|
722
735
|
*/
|
|
723
|
-
|
|
736
|
+
messages_last: string;
|
|
724
737
|
/**
|
|
725
|
-
*
|
|
738
|
+
* Copy message
|
|
726
739
|
*/
|
|
727
|
-
|
|
740
|
+
messages_copy: string;
|
|
741
|
+
/**
|
|
742
|
+
* Undo message
|
|
743
|
+
*/
|
|
744
|
+
messages_undo: string;
|
|
745
|
+
/**
|
|
746
|
+
* Redo message
|
|
747
|
+
*/
|
|
748
|
+
messages_redo: string;
|
|
749
|
+
/**
|
|
750
|
+
* List available models
|
|
751
|
+
*/
|
|
752
|
+
model_list: string;
|
|
753
|
+
/**
|
|
754
|
+
* Next recent model
|
|
755
|
+
*/
|
|
756
|
+
model_cycle_recent: string;
|
|
757
|
+
/**
|
|
758
|
+
* Previous recent model
|
|
759
|
+
*/
|
|
760
|
+
model_cycle_recent_reverse: string;
|
|
761
|
+
/**
|
|
762
|
+
* List agents
|
|
763
|
+
*/
|
|
764
|
+
agent_list: string;
|
|
765
|
+
/**
|
|
766
|
+
* Next agent
|
|
767
|
+
*/
|
|
768
|
+
agent_cycle: string;
|
|
769
|
+
/**
|
|
770
|
+
* Previous agent
|
|
771
|
+
*/
|
|
772
|
+
agent_cycle_reverse: string;
|
|
728
773
|
/**
|
|
729
774
|
* Clear input field
|
|
730
775
|
*/
|
|
@@ -742,61 +787,53 @@ export type KeybindsConfig = {
|
|
|
742
787
|
*/
|
|
743
788
|
input_newline: string;
|
|
744
789
|
/**
|
|
745
|
-
*
|
|
790
|
+
* @deprecated use agent_cycle. Next mode
|
|
746
791
|
*/
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Scroll messages down by one page
|
|
750
|
-
*/
|
|
751
|
-
messages_page_down: string;
|
|
752
|
-
/**
|
|
753
|
-
* Scroll messages up by half page
|
|
754
|
-
*/
|
|
755
|
-
messages_half_page_up: string;
|
|
792
|
+
switch_mode: string;
|
|
756
793
|
/**
|
|
757
|
-
*
|
|
794
|
+
* @deprecated use agent_cycle_reverse. Previous mode
|
|
758
795
|
*/
|
|
759
|
-
|
|
796
|
+
switch_mode_reverse: string;
|
|
760
797
|
/**
|
|
761
|
-
*
|
|
798
|
+
* @deprecated use agent_cycle. Next agent
|
|
762
799
|
*/
|
|
763
|
-
|
|
800
|
+
switch_agent: string;
|
|
764
801
|
/**
|
|
765
|
-
*
|
|
802
|
+
* @deprecated use agent_cycle_reverse. Previous agent
|
|
766
803
|
*/
|
|
767
|
-
|
|
804
|
+
switch_agent_reverse: string;
|
|
768
805
|
/**
|
|
769
|
-
*
|
|
806
|
+
* @deprecated Currently not available. List files
|
|
770
807
|
*/
|
|
771
|
-
|
|
808
|
+
file_list: string;
|
|
772
809
|
/**
|
|
773
|
-
*
|
|
810
|
+
* @deprecated Close file
|
|
774
811
|
*/
|
|
775
|
-
|
|
812
|
+
file_close: string;
|
|
776
813
|
/**
|
|
777
|
-
*
|
|
814
|
+
* @deprecated Search file
|
|
778
815
|
*/
|
|
779
|
-
|
|
816
|
+
file_search: string;
|
|
780
817
|
/**
|
|
781
|
-
*
|
|
818
|
+
* @deprecated Split/unified diff
|
|
782
819
|
*/
|
|
783
|
-
|
|
820
|
+
file_diff_toggle: string;
|
|
784
821
|
/**
|
|
785
|
-
* @deprecated
|
|
822
|
+
* @deprecated Navigate to previous message
|
|
786
823
|
*/
|
|
787
|
-
|
|
824
|
+
messages_previous: string;
|
|
788
825
|
/**
|
|
789
|
-
*
|
|
826
|
+
* @deprecated Navigate to next message
|
|
790
827
|
*/
|
|
791
|
-
|
|
828
|
+
messages_next: string;
|
|
792
829
|
/**
|
|
793
|
-
*
|
|
830
|
+
* @deprecated Toggle layout
|
|
794
831
|
*/
|
|
795
|
-
|
|
832
|
+
messages_layout_toggle: string;
|
|
796
833
|
/**
|
|
797
|
-
*
|
|
834
|
+
* @deprecated use messages_undo. Revert message
|
|
798
835
|
*/
|
|
799
|
-
|
|
836
|
+
messages_revert: string;
|
|
800
837
|
};
|
|
801
838
|
export type AgentConfig = {
|
|
802
839
|
model?: string;
|
|
@@ -811,22 +848,22 @@ export type AgentConfig = {
|
|
|
811
848
|
* Description of when to use the agent
|
|
812
849
|
*/
|
|
813
850
|
description?: string;
|
|
814
|
-
mode?:
|
|
851
|
+
mode?: "subagent" | "primary" | "all";
|
|
815
852
|
permission?: {
|
|
816
|
-
edit?:
|
|
817
|
-
bash?:
|
|
818
|
-
[key: string]:
|
|
853
|
+
edit?: "ask" | "allow" | "deny";
|
|
854
|
+
bash?: ("ask" | "allow" | "deny") | {
|
|
855
|
+
[key: string]: "ask" | "allow" | "deny";
|
|
819
856
|
};
|
|
820
|
-
webfetch?:
|
|
857
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
821
858
|
};
|
|
822
859
|
[key: string]: unknown | string | number | {
|
|
823
860
|
[key: string]: boolean;
|
|
824
|
-
} | boolean |
|
|
825
|
-
edit?:
|
|
826
|
-
bash?:
|
|
827
|
-
[key: string]:
|
|
861
|
+
} | boolean | ("subagent" | "primary" | "all") | {
|
|
862
|
+
edit?: "ask" | "allow" | "deny";
|
|
863
|
+
bash?: ("ask" | "allow" | "deny") | {
|
|
864
|
+
[key: string]: "ask" | "allow" | "deny";
|
|
828
865
|
};
|
|
829
|
-
webfetch?:
|
|
866
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
830
867
|
} | undefined;
|
|
831
868
|
};
|
|
832
869
|
export type Provider = {
|
|
@@ -865,7 +902,7 @@ export type McpLocalConfig = {
|
|
|
865
902
|
/**
|
|
866
903
|
* Type of MCP server connection
|
|
867
904
|
*/
|
|
868
|
-
type:
|
|
905
|
+
type: "local";
|
|
869
906
|
/**
|
|
870
907
|
* Command and arguments to run the MCP server
|
|
871
908
|
*/
|
|
@@ -885,7 +922,7 @@ export type McpRemoteConfig = {
|
|
|
885
922
|
/**
|
|
886
923
|
* Type of MCP server connection
|
|
887
924
|
*/
|
|
888
|
-
type:
|
|
925
|
+
type: "remote";
|
|
889
926
|
/**
|
|
890
927
|
* URL of the remote MCP server
|
|
891
928
|
*/
|
|
@@ -909,7 +946,7 @@ export type _Error = {
|
|
|
909
946
|
};
|
|
910
947
|
export type TextPartInput = {
|
|
911
948
|
id?: string;
|
|
912
|
-
type:
|
|
949
|
+
type: "text";
|
|
913
950
|
text: string;
|
|
914
951
|
synthetic?: boolean;
|
|
915
952
|
time?: {
|
|
@@ -919,7 +956,7 @@ export type TextPartInput = {
|
|
|
919
956
|
};
|
|
920
957
|
export type FilePartInput = {
|
|
921
958
|
id?: string;
|
|
922
|
-
type:
|
|
959
|
+
type: "file";
|
|
923
960
|
mime: string;
|
|
924
961
|
filename?: string;
|
|
925
962
|
url: string;
|
|
@@ -927,7 +964,7 @@ export type FilePartInput = {
|
|
|
927
964
|
};
|
|
928
965
|
export type AgentPartInput = {
|
|
929
966
|
id?: string;
|
|
930
|
-
type:
|
|
967
|
+
type: "agent";
|
|
931
968
|
name: string;
|
|
932
969
|
source?: {
|
|
933
970
|
value: string;
|
|
@@ -952,15 +989,16 @@ export type File = {
|
|
|
952
989
|
export type Agent = {
|
|
953
990
|
name: string;
|
|
954
991
|
description?: string;
|
|
955
|
-
mode:
|
|
992
|
+
mode: "subagent" | "primary" | "all";
|
|
993
|
+
builtIn: boolean;
|
|
956
994
|
topP?: number;
|
|
957
995
|
temperature?: number;
|
|
958
996
|
permission: {
|
|
959
|
-
edit:
|
|
997
|
+
edit: "ask" | "allow" | "deny";
|
|
960
998
|
bash: {
|
|
961
|
-
[key: string]:
|
|
999
|
+
[key: string]: "ask" | "allow" | "deny";
|
|
962
1000
|
};
|
|
963
|
-
webfetch?:
|
|
1001
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
964
1002
|
};
|
|
965
1003
|
model?: {
|
|
966
1004
|
modelID: string;
|
|
@@ -974,6 +1012,28 @@ export type Agent = {
|
|
|
974
1012
|
[key: string]: unknown;
|
|
975
1013
|
};
|
|
976
1014
|
};
|
|
1015
|
+
export type Auth = ({
|
|
1016
|
+
type: "oauth";
|
|
1017
|
+
} & OAuth) | ({
|
|
1018
|
+
type: "api";
|
|
1019
|
+
} & ApiAuth) | ({
|
|
1020
|
+
type: "wellknown";
|
|
1021
|
+
} & WellKnownAuth);
|
|
1022
|
+
export type OAuth = {
|
|
1023
|
+
type: "oauth";
|
|
1024
|
+
refresh: string;
|
|
1025
|
+
access: string;
|
|
1026
|
+
expires: number;
|
|
1027
|
+
};
|
|
1028
|
+
export type ApiAuth = {
|
|
1029
|
+
type: "api";
|
|
1030
|
+
key: string;
|
|
1031
|
+
};
|
|
1032
|
+
export type WellKnownAuth = {
|
|
1033
|
+
type: "wellknown";
|
|
1034
|
+
key: string;
|
|
1035
|
+
token: string;
|
|
1036
|
+
};
|
|
977
1037
|
export type EventSubscribeData = {
|
|
978
1038
|
body?: never;
|
|
979
1039
|
path?: never;
|
|
@@ -1040,7 +1100,10 @@ export type SessionListResponses = {
|
|
|
1040
1100
|
};
|
|
1041
1101
|
export type SessionListResponse = SessionListResponses[keyof SessionListResponses];
|
|
1042
1102
|
export type SessionCreateData = {
|
|
1043
|
-
body?:
|
|
1103
|
+
body?: {
|
|
1104
|
+
parentID?: string;
|
|
1105
|
+
title?: string;
|
|
1106
|
+
};
|
|
1044
1107
|
path?: never;
|
|
1045
1108
|
query?: never;
|
|
1046
1109
|
url: "/session";
|
|
@@ -1106,6 +1169,21 @@ export type SessionUpdateResponses = {
|
|
|
1106
1169
|
200: Session;
|
|
1107
1170
|
};
|
|
1108
1171
|
export type SessionUpdateResponse = SessionUpdateResponses[keyof SessionUpdateResponses];
|
|
1172
|
+
export type SessionChildrenData = {
|
|
1173
|
+
body?: never;
|
|
1174
|
+
path: {
|
|
1175
|
+
id: string;
|
|
1176
|
+
};
|
|
1177
|
+
query?: never;
|
|
1178
|
+
url: "/session/{id}/children";
|
|
1179
|
+
};
|
|
1180
|
+
export type SessionChildrenResponses = {
|
|
1181
|
+
/**
|
|
1182
|
+
* List of children
|
|
1183
|
+
*/
|
|
1184
|
+
200: Array<Session>;
|
|
1185
|
+
};
|
|
1186
|
+
export type SessionChildrenResponse = SessionChildrenResponses[keyof SessionChildrenResponses];
|
|
1109
1187
|
export type SessionInitData = {
|
|
1110
1188
|
body?: {
|
|
1111
1189
|
messageID: string;
|
|
@@ -1609,6 +1687,45 @@ export type TuiExecuteCommandResponses = {
|
|
|
1609
1687
|
200: boolean;
|
|
1610
1688
|
};
|
|
1611
1689
|
export type TuiExecuteCommandResponse = TuiExecuteCommandResponses[keyof TuiExecuteCommandResponses];
|
|
1690
|
+
export type TuiShowToastData = {
|
|
1691
|
+
body?: {
|
|
1692
|
+
title?: string;
|
|
1693
|
+
message: string;
|
|
1694
|
+
variant: "info" | "success" | "warning" | "error";
|
|
1695
|
+
};
|
|
1696
|
+
path?: never;
|
|
1697
|
+
query?: never;
|
|
1698
|
+
url: "/tui/show-toast";
|
|
1699
|
+
};
|
|
1700
|
+
export type TuiShowToastResponses = {
|
|
1701
|
+
/**
|
|
1702
|
+
* Toast notification shown successfully
|
|
1703
|
+
*/
|
|
1704
|
+
200: boolean;
|
|
1705
|
+
};
|
|
1706
|
+
export type TuiShowToastResponse = TuiShowToastResponses[keyof TuiShowToastResponses];
|
|
1707
|
+
export type AuthSetData = {
|
|
1708
|
+
body?: Auth;
|
|
1709
|
+
path: {
|
|
1710
|
+
id: string;
|
|
1711
|
+
};
|
|
1712
|
+
query?: never;
|
|
1713
|
+
url: "/auth/{id}";
|
|
1714
|
+
};
|
|
1715
|
+
export type AuthSetErrors = {
|
|
1716
|
+
/**
|
|
1717
|
+
* Bad request
|
|
1718
|
+
*/
|
|
1719
|
+
400: _Error;
|
|
1720
|
+
};
|
|
1721
|
+
export type AuthSetError = AuthSetErrors[keyof AuthSetErrors];
|
|
1722
|
+
export type AuthSetResponses = {
|
|
1723
|
+
/**
|
|
1724
|
+
* Successfully set authentication credentials
|
|
1725
|
+
*/
|
|
1726
|
+
200: boolean;
|
|
1727
|
+
};
|
|
1728
|
+
export type AuthSetResponse = AuthSetResponses[keyof AuthSetResponses];
|
|
1612
1729
|
export type ClientOptions = {
|
|
1613
1730
|
baseUrl: `${string}://${string}` | (string & {});
|
|
1614
1731
|
};
|
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
|
+
}
|