@opencode-ai/sdk 0.1.0-alpha.15 → 0.1.0-alpha.17
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/CHANGELOG.md +22 -0
- package/README.md +9 -27
- package/client.d.mts +15 -14
- package/client.d.mts.map +1 -1
- package/client.d.ts +15 -14
- package/client.d.ts.map +1 -1
- package/client.js +12 -9
- package/client.js.map +1 -1
- package/client.mjs +14 -11
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/app.d.mts +49 -2
- package/resources/app.d.mts.map +1 -1
- package/resources/app.d.ts +49 -2
- package/resources/app.d.ts.map +1 -1
- package/resources/app.js +12 -0
- package/resources/app.js.map +1 -1
- package/resources/app.mjs +12 -0
- package/resources/app.mjs.map +1 -1
- package/resources/config.d.mts +120 -34
- package/resources/config.d.mts.map +1 -1
- package/resources/config.d.ts +120 -34
- package/resources/config.d.ts.map +1 -1
- package/resources/config.js.map +1 -1
- package/resources/config.mjs.map +1 -1
- package/resources/event.d.mts +14 -15
- package/resources/event.d.mts.map +1 -1
- package/resources/event.d.ts +14 -15
- package/resources/event.d.ts.map +1 -1
- package/resources/file.d.mts +10 -12
- package/resources/file.d.mts.map +1 -1
- package/resources/file.d.ts +10 -12
- package/resources/file.d.ts.map +1 -1
- package/resources/file.js +3 -3
- package/resources/file.js.map +1 -1
- package/resources/file.mjs +1 -1
- package/resources/file.mjs.map +1 -1
- package/resources/find.d.mts +48 -23
- package/resources/find.d.mts.map +1 -1
- package/resources/find.d.ts +48 -23
- package/resources/find.d.ts.map +1 -1
- package/resources/index.d.mts +4 -4
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +4 -4
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +2 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -2
- package/resources/index.mjs.map +1 -1
- package/resources/session.d.mts +81 -24
- package/resources/session.d.mts.map +1 -1
- package/resources/session.d.ts +81 -24
- package/resources/session.d.ts.map +1 -1
- package/resources/shared.d.mts +4 -0
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +4 -0
- package/resources/shared.d.ts.map +1 -1
- package/src/client.ts +53 -22
- package/src/resources/app.ts +72 -3
- package/src/resources/config.ts +139 -34
- package/src/resources/event.ts +21 -19
- package/src/resources/file.ts +14 -15
- package/src/resources/find.ts +60 -22
- package/src/resources/index.ts +23 -4
- package/src/resources/session.ts +128 -34
- package/src/resources/shared.ts +6 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/session.d.ts
CHANGED
|
@@ -49,7 +49,6 @@ export interface AssistantMessage {
|
|
|
49
49
|
id: string;
|
|
50
50
|
cost: number;
|
|
51
51
|
modelID: string;
|
|
52
|
-
parts: Array<AssistantMessagePart>;
|
|
53
52
|
path: AssistantMessage.Path;
|
|
54
53
|
providerID: string;
|
|
55
54
|
role: 'assistant';
|
|
@@ -57,7 +56,7 @@ export interface AssistantMessage {
|
|
|
57
56
|
system: Array<string>;
|
|
58
57
|
time: AssistantMessage.Time;
|
|
59
58
|
tokens: AssistantMessage.Tokens;
|
|
60
|
-
error?: Shared.ProviderAuthError | Shared.UnknownError | AssistantMessage.MessageOutputLengthError;
|
|
59
|
+
error?: Shared.ProviderAuthError | Shared.UnknownError | AssistantMessage.MessageOutputLengthError | Shared.MessageAbortedError;
|
|
61
60
|
summary?: boolean;
|
|
62
61
|
}
|
|
63
62
|
export declare namespace AssistantMessage {
|
|
@@ -86,28 +85,17 @@ export declare namespace AssistantMessage {
|
|
|
86
85
|
name: 'MessageOutputLengthError';
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
|
-
export type AssistantMessagePart = TextPart | ToolPart | StepStartPart;
|
|
90
88
|
export interface FilePart {
|
|
89
|
+
id: string;
|
|
90
|
+
messageID: string;
|
|
91
91
|
mime: string;
|
|
92
|
+
sessionID: string;
|
|
92
93
|
type: 'file';
|
|
93
94
|
url: string;
|
|
94
95
|
filename?: string;
|
|
95
96
|
}
|
|
96
|
-
export type Message =
|
|
97
|
-
export
|
|
98
|
-
interface UserMessage {
|
|
99
|
-
id: string;
|
|
100
|
-
parts: Array<SessionAPI.UserMessagePart>;
|
|
101
|
-
role: 'user';
|
|
102
|
-
sessionID: string;
|
|
103
|
-
time: UserMessage.Time;
|
|
104
|
-
}
|
|
105
|
-
namespace UserMessage {
|
|
106
|
-
interface Time {
|
|
107
|
-
created: number;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
97
|
+
export type Message = UserMessage | AssistantMessage;
|
|
98
|
+
export type Part = TextPart | FilePart | ToolPart | StepStartPart | StepFinishPart | SnapshotPart;
|
|
111
99
|
export interface Session {
|
|
112
100
|
id: string;
|
|
113
101
|
time: Session.Time;
|
|
@@ -131,20 +119,69 @@ export declare namespace Session {
|
|
|
131
119
|
url: string;
|
|
132
120
|
}
|
|
133
121
|
}
|
|
122
|
+
export interface SnapshotPart {
|
|
123
|
+
id: string;
|
|
124
|
+
messageID: string;
|
|
125
|
+
sessionID: string;
|
|
126
|
+
snapshot: string;
|
|
127
|
+
type: 'snapshot';
|
|
128
|
+
}
|
|
129
|
+
export interface StepFinishPart {
|
|
130
|
+
id: string;
|
|
131
|
+
cost: number;
|
|
132
|
+
messageID: string;
|
|
133
|
+
sessionID: string;
|
|
134
|
+
tokens: StepFinishPart.Tokens;
|
|
135
|
+
type: 'step-finish';
|
|
136
|
+
}
|
|
137
|
+
export declare namespace StepFinishPart {
|
|
138
|
+
interface Tokens {
|
|
139
|
+
cache: Tokens.Cache;
|
|
140
|
+
input: number;
|
|
141
|
+
output: number;
|
|
142
|
+
reasoning: number;
|
|
143
|
+
}
|
|
144
|
+
namespace Tokens {
|
|
145
|
+
interface Cache {
|
|
146
|
+
read: number;
|
|
147
|
+
write: number;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
134
151
|
export interface StepStartPart {
|
|
152
|
+
id: string;
|
|
153
|
+
messageID: string;
|
|
154
|
+
sessionID: string;
|
|
135
155
|
type: 'step-start';
|
|
136
156
|
}
|
|
137
157
|
export interface TextPart {
|
|
158
|
+
id: string;
|
|
159
|
+
messageID: string;
|
|
160
|
+
sessionID: string;
|
|
138
161
|
text: string;
|
|
139
162
|
type: 'text';
|
|
163
|
+
synthetic?: boolean;
|
|
164
|
+
time?: TextPart.Time;
|
|
165
|
+
}
|
|
166
|
+
export declare namespace TextPart {
|
|
167
|
+
interface Time {
|
|
168
|
+
start: number;
|
|
169
|
+
end?: number;
|
|
170
|
+
}
|
|
140
171
|
}
|
|
141
172
|
export interface ToolPart {
|
|
142
173
|
id: string;
|
|
174
|
+
callID: string;
|
|
175
|
+
messageID: string;
|
|
176
|
+
sessionID: string;
|
|
143
177
|
state: ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError;
|
|
144
178
|
tool: string;
|
|
145
179
|
type: 'tool';
|
|
146
180
|
}
|
|
147
181
|
export interface ToolStateCompleted {
|
|
182
|
+
input: {
|
|
183
|
+
[key: string]: unknown;
|
|
184
|
+
};
|
|
148
185
|
metadata: {
|
|
149
186
|
[key: string]: unknown;
|
|
150
187
|
};
|
|
@@ -152,7 +189,6 @@ export interface ToolStateCompleted {
|
|
|
152
189
|
status: 'completed';
|
|
153
190
|
time: ToolStateCompleted.Time;
|
|
154
191
|
title: string;
|
|
155
|
-
input?: unknown;
|
|
156
192
|
}
|
|
157
193
|
export declare namespace ToolStateCompleted {
|
|
158
194
|
interface Time {
|
|
@@ -162,9 +198,11 @@ export declare namespace ToolStateCompleted {
|
|
|
162
198
|
}
|
|
163
199
|
export interface ToolStateError {
|
|
164
200
|
error: string;
|
|
201
|
+
input: {
|
|
202
|
+
[key: string]: unknown;
|
|
203
|
+
};
|
|
165
204
|
status: 'error';
|
|
166
205
|
time: ToolStateError.Time;
|
|
167
|
-
input?: unknown;
|
|
168
206
|
}
|
|
169
207
|
export declare namespace ToolStateError {
|
|
170
208
|
interface Time {
|
|
@@ -189,19 +227,38 @@ export declare namespace ToolStateRunning {
|
|
|
189
227
|
start: number;
|
|
190
228
|
}
|
|
191
229
|
}
|
|
192
|
-
export
|
|
230
|
+
export interface UserMessage {
|
|
231
|
+
id: string;
|
|
232
|
+
role: 'user';
|
|
233
|
+
sessionID: string;
|
|
234
|
+
time: UserMessage.Time;
|
|
235
|
+
}
|
|
236
|
+
export declare namespace UserMessage {
|
|
237
|
+
interface Time {
|
|
238
|
+
created: number;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
193
241
|
export type SessionListResponse = Array<Session>;
|
|
194
242
|
export type SessionDeleteResponse = boolean;
|
|
195
243
|
export type SessionAbortResponse = boolean;
|
|
196
244
|
export type SessionInitResponse = boolean;
|
|
197
|
-
export type SessionMessagesResponse = Array<
|
|
245
|
+
export type SessionMessagesResponse = Array<SessionMessagesResponse.SessionMessagesResponseItem>;
|
|
246
|
+
export declare namespace SessionMessagesResponse {
|
|
247
|
+
interface SessionMessagesResponseItem {
|
|
248
|
+
info: SessionAPI.Message;
|
|
249
|
+
parts: Array<SessionAPI.Part>;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
198
252
|
export type SessionSummarizeResponse = boolean;
|
|
199
253
|
export interface SessionChatParams {
|
|
254
|
+
messageID: string;
|
|
255
|
+
mode: string;
|
|
200
256
|
modelID: string;
|
|
201
|
-
parts: Array<
|
|
257
|
+
parts: Array<FilePart | TextPart>;
|
|
202
258
|
providerID: string;
|
|
203
259
|
}
|
|
204
260
|
export interface SessionInitParams {
|
|
261
|
+
messageID: string;
|
|
205
262
|
modelID: string;
|
|
206
263
|
providerID: string;
|
|
207
264
|
}
|
|
@@ -210,6 +267,6 @@ export interface SessionSummarizeParams {
|
|
|
210
267
|
providerID: string;
|
|
211
268
|
}
|
|
212
269
|
export declare namespace SessionResource {
|
|
213
|
-
export { type AssistantMessage as AssistantMessage, type
|
|
270
|
+
export { type AssistantMessage as AssistantMessage, type FilePart as FilePart, type Message as Message, type Part as Part, type Session as Session, type SnapshotPart as SnapshotPart, type StepFinishPart as StepFinishPart, type StepStartPart as StepStartPart, type TextPart as TextPart, type ToolPart as ToolPart, type ToolStateCompleted as ToolStateCompleted, type ToolStateError as ToolStateError, type ToolStatePending as ToolStatePending, type ToolStateRunning as ToolStateRunning, type UserMessage as UserMessage, type SessionListResponse as SessionListResponse, type SessionDeleteResponse as SessionDeleteResponse, type SessionAbortResponse as SessionAbortResponse, type SessionInitResponse as SessionInitResponse, type SessionMessagesResponse as SessionMessagesResponse, type SessionSummarizeResponse as SessionSummarizeResponse, type SessionChatParams as SessionChatParams, type SessionInitParams as SessionInitParams, type SessionSummarizeParams as SessionSummarizeParams, };
|
|
214
271
|
}
|
|
215
272
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/resources/session.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,UAAU;OACf,KAAK,MAAM;OACX,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAGzB,qBAAa,eAAgB,SAAQ,WAAW;IAC9C;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAIrD;;OAEG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;IAI/D;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;IAI/E;;OAEG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;IAI7E;;OAEG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAA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I,gBAAgB,EACzC,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,WAAW,IAAI,WAAW,EAC/B,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;CACH"}
|
package/resources/shared.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.mts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC;IAE7B,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,yBAAiB,iBAAiB,CAAC;IACjC,UAAiB,IAAI;QACnB,OAAO,EAAE,MAAM,CAAC;QAEhB,UAAU,EAAE,MAAM,CAAC;KACpB;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;IAExB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,yBAAiB,YAAY,CAAC;IAC5B,UAAiB,IAAI;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB;CACF"}
|
|
1
|
+
{"version":3,"file":"shared.d.mts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IAEd,IAAI,EAAE,qBAAqB,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC;IAE7B,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,yBAAiB,iBAAiB,CAAC;IACjC,UAAiB,IAAI;QACnB,OAAO,EAAE,MAAM,CAAC;QAEhB,UAAU,EAAE,MAAM,CAAC;KACpB;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;IAExB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,yBAAiB,YAAY,CAAC;IAC5B,UAAiB,IAAI;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB;CACF"}
|
package/resources/shared.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC;IAE7B,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,yBAAiB,iBAAiB,CAAC;IACjC,UAAiB,IAAI;QACnB,OAAO,EAAE,MAAM,CAAC;QAEhB,UAAU,EAAE,MAAM,CAAC;KACpB;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;IAExB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,yBAAiB,YAAY,CAAC;IAC5B,UAAiB,IAAI;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB;CACF"}
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/resources/shared.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IAEd,IAAI,EAAE,qBAAqB,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC;IAE7B,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,yBAAiB,iBAAiB,CAAC;IACjC,UAAiB,IAAI;QACnB,OAAO,EAAE,MAAM,CAAC;QAEhB,UAAU,EAAE,MAAM,CAAC;KACpB;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;IAExB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,yBAAiB,YAAY,CAAC;IAC5B,UAAiB,IAAI;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB;CACF"}
|
package/src/client.ts
CHANGED
|
@@ -16,7 +16,16 @@ import * as Errors from './core/error';
|
|
|
16
16
|
import * as Uploads from './core/uploads';
|
|
17
17
|
import * as API from './resources/index';
|
|
18
18
|
import { APIPromise } from './core/api-promise';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
App,
|
|
21
|
+
AppInitResponse,
|
|
22
|
+
AppLogParams,
|
|
23
|
+
AppLogResponse,
|
|
24
|
+
AppModesResponse,
|
|
25
|
+
AppResource,
|
|
26
|
+
LogLevel,
|
|
27
|
+
Mode,
|
|
28
|
+
} from './resources/app';
|
|
20
29
|
import {
|
|
21
30
|
Config,
|
|
22
31
|
ConfigProvidersResponse,
|
|
@@ -28,7 +37,7 @@ import {
|
|
|
28
37
|
Provider,
|
|
29
38
|
} from './resources/config';
|
|
30
39
|
import { Event, EventListResponse } from './resources/event';
|
|
31
|
-
import { File, FileReadParams, FileReadResponse, FileStatusResponse } from './resources/file';
|
|
40
|
+
import { File, FileReadParams, FileReadResponse, FileResource, FileStatusResponse } from './resources/file';
|
|
32
41
|
import {
|
|
33
42
|
Find,
|
|
34
43
|
FindFilesParams,
|
|
@@ -37,12 +46,14 @@ import {
|
|
|
37
46
|
FindSymbolsResponse,
|
|
38
47
|
FindTextParams,
|
|
39
48
|
FindTextResponse,
|
|
49
|
+
Match,
|
|
50
|
+
Symbol,
|
|
40
51
|
} from './resources/find';
|
|
41
52
|
import {
|
|
42
53
|
AssistantMessage,
|
|
43
|
-
AssistantMessagePart,
|
|
44
54
|
FilePart,
|
|
45
55
|
Message,
|
|
56
|
+
Part,
|
|
46
57
|
Session,
|
|
47
58
|
SessionAbortResponse,
|
|
48
59
|
SessionChatParams,
|
|
@@ -54,6 +65,8 @@ import {
|
|
|
54
65
|
SessionResource,
|
|
55
66
|
SessionSummarizeParams,
|
|
56
67
|
SessionSummarizeResponse,
|
|
68
|
+
SnapshotPart,
|
|
69
|
+
StepFinishPart,
|
|
57
70
|
StepStartPart,
|
|
58
71
|
TextPart,
|
|
59
72
|
ToolPart,
|
|
@@ -61,14 +74,14 @@ import {
|
|
|
61
74
|
ToolStateError,
|
|
62
75
|
ToolStatePending,
|
|
63
76
|
ToolStateRunning,
|
|
64
|
-
|
|
77
|
+
UserMessage,
|
|
65
78
|
} from './resources/session';
|
|
66
79
|
import { type Fetch } from './internal/builtin-types';
|
|
67
80
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
68
81
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
69
82
|
import { readEnv } from './internal/utils/env';
|
|
70
83
|
import {
|
|
71
|
-
type LogLevel,
|
|
84
|
+
type LogLevel as ClientLogLevel,
|
|
72
85
|
type Logger,
|
|
73
86
|
formatRequestDetails,
|
|
74
87
|
loggerFor,
|
|
@@ -136,7 +149,7 @@ export interface ClientOptions {
|
|
|
136
149
|
*
|
|
137
150
|
* Defaults to process.env['OPENCODE_LOG'] or 'warn' if it isn't set.
|
|
138
151
|
*/
|
|
139
|
-
logLevel?:
|
|
152
|
+
logLevel?: ClientLogLevel | undefined;
|
|
140
153
|
|
|
141
154
|
/**
|
|
142
155
|
* Set the logger.
|
|
@@ -154,7 +167,7 @@ export class Opencode {
|
|
|
154
167
|
maxRetries: number;
|
|
155
168
|
timeout: number;
|
|
156
169
|
logger: Logger | undefined;
|
|
157
|
-
logLevel:
|
|
170
|
+
logLevel: ClientLogLevel | undefined;
|
|
158
171
|
fetchOptions: MergedRequestInit | undefined;
|
|
159
172
|
|
|
160
173
|
private fetch: Fetch;
|
|
@@ -201,7 +214,7 @@ export class Opencode {
|
|
|
201
214
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
202
215
|
*/
|
|
203
216
|
withOptions(options: Partial<ClientOptions>): this {
|
|
204
|
-
|
|
217
|
+
const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({
|
|
205
218
|
...this._options,
|
|
206
219
|
baseURL: this.baseURL,
|
|
207
220
|
maxRetries: this.maxRetries,
|
|
@@ -212,6 +225,7 @@ export class Opencode {
|
|
|
212
225
|
fetchOptions: this.fetchOptions,
|
|
213
226
|
...options,
|
|
214
227
|
});
|
|
228
|
+
return client;
|
|
215
229
|
}
|
|
216
230
|
|
|
217
231
|
/**
|
|
@@ -357,7 +371,9 @@ export class Opencode {
|
|
|
357
371
|
|
|
358
372
|
await this.prepareOptions(options);
|
|
359
373
|
|
|
360
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
374
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
375
|
+
retryCount: maxRetries - retriesRemaining,
|
|
376
|
+
});
|
|
361
377
|
|
|
362
378
|
await this.prepareRequest(req, { url, options });
|
|
363
379
|
|
|
@@ -435,7 +451,7 @@ export class Opencode {
|
|
|
435
451
|
} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
436
452
|
|
|
437
453
|
if (!response.ok) {
|
|
438
|
-
const shouldRetry = this.shouldRetry(response);
|
|
454
|
+
const shouldRetry = await this.shouldRetry(response);
|
|
439
455
|
if (retriesRemaining && shouldRetry) {
|
|
440
456
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
441
457
|
|
|
@@ -534,7 +550,7 @@ export class Opencode {
|
|
|
534
550
|
}
|
|
535
551
|
}
|
|
536
552
|
|
|
537
|
-
private shouldRetry(response: Response): boolean {
|
|
553
|
+
private async shouldRetry(response: Response): Promise<boolean> {
|
|
538
554
|
// Note this is not a standard header.
|
|
539
555
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
540
556
|
|
|
@@ -611,10 +627,10 @@ export class Opencode {
|
|
|
611
627
|
return sleepSeconds * jitter * 1000;
|
|
612
628
|
}
|
|
613
629
|
|
|
614
|
-
buildRequest(
|
|
630
|
+
async buildRequest(
|
|
615
631
|
inputOptions: FinalRequestOptions,
|
|
616
632
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
617
|
-
): { req: FinalizedRequestInit; url: string; timeout: number } {
|
|
633
|
+
): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> {
|
|
618
634
|
const options = { ...inputOptions };
|
|
619
635
|
const { method, path, query, defaultBaseURL } = options;
|
|
620
636
|
|
|
@@ -622,7 +638,7 @@ export class Opencode {
|
|
|
622
638
|
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
623
639
|
options.timeout = options.timeout ?? this.timeout;
|
|
624
640
|
const { bodyHeaders, body } = this.buildBody({ options });
|
|
625
|
-
const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
641
|
+
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
626
642
|
|
|
627
643
|
const req: FinalizedRequestInit = {
|
|
628
644
|
method,
|
|
@@ -638,7 +654,7 @@ export class Opencode {
|
|
|
638
654
|
return { req, url, timeout: options.timeout };
|
|
639
655
|
}
|
|
640
656
|
|
|
641
|
-
private buildHeaders({
|
|
657
|
+
private async buildHeaders({
|
|
642
658
|
options,
|
|
643
659
|
method,
|
|
644
660
|
bodyHeaders,
|
|
@@ -648,7 +664,7 @@ export class Opencode {
|
|
|
648
664
|
method: HTTPMethod;
|
|
649
665
|
bodyHeaders: HeadersLike;
|
|
650
666
|
retryCount: number;
|
|
651
|
-
}): Headers {
|
|
667
|
+
}): Promise<Headers> {
|
|
652
668
|
let idempotencyHeaders: HeadersLike = {};
|
|
653
669
|
if (this.idempotencyHeader && method !== 'get') {
|
|
654
670
|
if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
|
|
@@ -733,14 +749,14 @@ export class Opencode {
|
|
|
733
749
|
event: API.Event = new API.Event(this);
|
|
734
750
|
app: API.AppResource = new API.AppResource(this);
|
|
735
751
|
find: API.Find = new API.Find(this);
|
|
736
|
-
file: API.
|
|
752
|
+
file: API.FileResource = new API.FileResource(this);
|
|
737
753
|
config: API.ConfigResource = new API.ConfigResource(this);
|
|
738
754
|
session: API.SessionResource = new API.SessionResource(this);
|
|
739
755
|
}
|
|
740
756
|
Opencode.Event = Event;
|
|
741
757
|
Opencode.AppResource = AppResource;
|
|
742
758
|
Opencode.Find = Find;
|
|
743
|
-
Opencode.
|
|
759
|
+
Opencode.FileResource = FileResource;
|
|
744
760
|
Opencode.ConfigResource = ConfigResource;
|
|
745
761
|
Opencode.SessionResource = SessionResource;
|
|
746
762
|
export declare namespace Opencode {
|
|
@@ -748,10 +764,21 @@ export declare namespace Opencode {
|
|
|
748
764
|
|
|
749
765
|
export { Event as Event, type EventListResponse as EventListResponse };
|
|
750
766
|
|
|
751
|
-
export {
|
|
767
|
+
export {
|
|
768
|
+
AppResource as AppResource,
|
|
769
|
+
type App as App,
|
|
770
|
+
type LogLevel as LogLevel,
|
|
771
|
+
type Mode as Mode,
|
|
772
|
+
type AppInitResponse as AppInitResponse,
|
|
773
|
+
type AppLogResponse as AppLogResponse,
|
|
774
|
+
type AppModesResponse as AppModesResponse,
|
|
775
|
+
type AppLogParams as AppLogParams,
|
|
776
|
+
};
|
|
752
777
|
|
|
753
778
|
export {
|
|
754
779
|
Find as Find,
|
|
780
|
+
type Match as Match,
|
|
781
|
+
type Symbol as Symbol,
|
|
755
782
|
type FindFilesResponse as FindFilesResponse,
|
|
756
783
|
type FindSymbolsResponse as FindSymbolsResponse,
|
|
757
784
|
type FindTextResponse as FindTextResponse,
|
|
@@ -761,7 +788,8 @@ export declare namespace Opencode {
|
|
|
761
788
|
};
|
|
762
789
|
|
|
763
790
|
export {
|
|
764
|
-
|
|
791
|
+
FileResource as FileResource,
|
|
792
|
+
type File as File,
|
|
765
793
|
type FileReadResponse as FileReadResponse,
|
|
766
794
|
type FileStatusResponse as FileStatusResponse,
|
|
767
795
|
type FileReadParams as FileReadParams,
|
|
@@ -781,10 +809,12 @@ export declare namespace Opencode {
|
|
|
781
809
|
export {
|
|
782
810
|
SessionResource as SessionResource,
|
|
783
811
|
type AssistantMessage as AssistantMessage,
|
|
784
|
-
type AssistantMessagePart as AssistantMessagePart,
|
|
785
812
|
type FilePart as FilePart,
|
|
786
813
|
type Message as Message,
|
|
814
|
+
type Part as Part,
|
|
787
815
|
type Session as Session,
|
|
816
|
+
type SnapshotPart as SnapshotPart,
|
|
817
|
+
type StepFinishPart as StepFinishPart,
|
|
788
818
|
type StepStartPart as StepStartPart,
|
|
789
819
|
type TextPart as TextPart,
|
|
790
820
|
type ToolPart as ToolPart,
|
|
@@ -792,7 +822,7 @@ export declare namespace Opencode {
|
|
|
792
822
|
type ToolStateError as ToolStateError,
|
|
793
823
|
type ToolStatePending as ToolStatePending,
|
|
794
824
|
type ToolStateRunning as ToolStateRunning,
|
|
795
|
-
type
|
|
825
|
+
type UserMessage as UserMessage,
|
|
796
826
|
type SessionListResponse as SessionListResponse,
|
|
797
827
|
type SessionDeleteResponse as SessionDeleteResponse,
|
|
798
828
|
type SessionAbortResponse as SessionAbortResponse,
|
|
@@ -804,6 +834,7 @@ export declare namespace Opencode {
|
|
|
804
834
|
type SessionSummarizeParams as SessionSummarizeParams,
|
|
805
835
|
};
|
|
806
836
|
|
|
837
|
+
export type MessageAbortedError = API.MessageAbortedError;
|
|
807
838
|
export type ProviderAuthError = API.ProviderAuthError;
|
|
808
839
|
export type UnknownError = API.UnknownError;
|
|
809
840
|
}
|
package/src/resources/app.ts
CHANGED
|
@@ -18,6 +18,20 @@ export class AppResource extends APIResource {
|
|
|
18
18
|
init(options?: RequestOptions): APIPromise<AppInitResponse> {
|
|
19
19
|
return this._client.post('/app/init', options);
|
|
20
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
|
+
}
|
|
21
35
|
}
|
|
22
36
|
|
|
23
37
|
export interface App {
|
|
@@ -28,8 +42,6 @@ export interface App {
|
|
|
28
42
|
path: App.Path;
|
|
29
43
|
|
|
30
44
|
time: App.Time;
|
|
31
|
-
|
|
32
|
-
user: string;
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
export namespace App {
|
|
@@ -50,8 +62,65 @@ export namespace App {
|
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Log level
|
|
67
|
+
*/
|
|
68
|
+
export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
69
|
+
|
|
70
|
+
export interface Mode {
|
|
71
|
+
name: string;
|
|
72
|
+
|
|
73
|
+
tools: { [key: string]: boolean };
|
|
74
|
+
|
|
75
|
+
model?: Mode.Model;
|
|
76
|
+
|
|
77
|
+
prompt?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export namespace Mode {
|
|
81
|
+
export interface Model {
|
|
82
|
+
modelID: string;
|
|
83
|
+
|
|
84
|
+
providerID: string;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
53
88
|
export type AppInitResponse = boolean;
|
|
54
89
|
|
|
90
|
+
export type AppLogResponse = boolean;
|
|
91
|
+
|
|
92
|
+
export type AppModesResponse = Array<Mode>;
|
|
93
|
+
|
|
94
|
+
export interface AppLogParams {
|
|
95
|
+
/**
|
|
96
|
+
* Log level
|
|
97
|
+
*/
|
|
98
|
+
level: 'debug' | 'info' | 'error' | 'warn';
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Log message
|
|
102
|
+
*/
|
|
103
|
+
message: string;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Service name for the log entry
|
|
107
|
+
*/
|
|
108
|
+
service: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Additional metadata for the log entry
|
|
112
|
+
*/
|
|
113
|
+
extra?: { [key: string]: unknown };
|
|
114
|
+
}
|
|
115
|
+
|
|
55
116
|
export declare namespace AppResource {
|
|
56
|
-
export {
|
|
117
|
+
export {
|
|
118
|
+
type App as App,
|
|
119
|
+
type LogLevel as LogLevel,
|
|
120
|
+
type Mode as Mode,
|
|
121
|
+
type AppInitResponse as AppInitResponse,
|
|
122
|
+
type AppLogResponse as AppLogResponse,
|
|
123
|
+
type AppModesResponse as AppModesResponse,
|
|
124
|
+
type AppLogParams as AppLogParams,
|
|
125
|
+
};
|
|
57
126
|
}
|