@opencode-ai/sdk 0.1.0-alpha.15 → 0.1.0-alpha.16
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 +13 -0
- 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 +79 -20
- package/resources/session.d.mts.map +1 -1
- package/resources/session.d.ts +79 -20
- 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 +51 -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 +22 -4
- package/src/resources/session.ts +121 -26
- 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,26 +85,24 @@ 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
|
-
|
|
97
|
+
export type Message = UserMessage | AssistantMessage;
|
|
98
|
+
export type Part = TextPart | FilePart | ToolPart | StepStartPart | StepFinishPart | Part.UnionMember5;
|
|
99
|
+
export declare namespace Part {
|
|
100
|
+
interface UnionMember5 {
|
|
99
101
|
id: string;
|
|
100
|
-
|
|
101
|
-
role: 'user';
|
|
102
|
+
messageID: string;
|
|
102
103
|
sessionID: string;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
namespace UserMessage {
|
|
106
|
-
interface Time {
|
|
107
|
-
created: number;
|
|
108
|
-
}
|
|
104
|
+
snapshot: string;
|
|
105
|
+
type: 'snapshot';
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
export interface Session {
|
|
@@ -131,20 +128,62 @@ export declare namespace Session {
|
|
|
131
128
|
url: string;
|
|
132
129
|
}
|
|
133
130
|
}
|
|
131
|
+
export interface StepFinishPart {
|
|
132
|
+
id: string;
|
|
133
|
+
cost: number;
|
|
134
|
+
messageID: string;
|
|
135
|
+
sessionID: string;
|
|
136
|
+
tokens: StepFinishPart.Tokens;
|
|
137
|
+
type: 'step-finish';
|
|
138
|
+
}
|
|
139
|
+
export declare namespace StepFinishPart {
|
|
140
|
+
interface Tokens {
|
|
141
|
+
cache: Tokens.Cache;
|
|
142
|
+
input: number;
|
|
143
|
+
output: number;
|
|
144
|
+
reasoning: number;
|
|
145
|
+
}
|
|
146
|
+
namespace Tokens {
|
|
147
|
+
interface Cache {
|
|
148
|
+
read: number;
|
|
149
|
+
write: number;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
134
153
|
export interface StepStartPart {
|
|
154
|
+
id: string;
|
|
155
|
+
messageID: string;
|
|
156
|
+
sessionID: string;
|
|
135
157
|
type: 'step-start';
|
|
136
158
|
}
|
|
137
159
|
export interface TextPart {
|
|
160
|
+
id: string;
|
|
161
|
+
messageID: string;
|
|
162
|
+
sessionID: string;
|
|
138
163
|
text: string;
|
|
139
164
|
type: 'text';
|
|
165
|
+
synthetic?: boolean;
|
|
166
|
+
time?: TextPart.Time;
|
|
167
|
+
}
|
|
168
|
+
export declare namespace TextPart {
|
|
169
|
+
interface Time {
|
|
170
|
+
start: number;
|
|
171
|
+
end?: number;
|
|
172
|
+
}
|
|
140
173
|
}
|
|
141
174
|
export interface ToolPart {
|
|
142
175
|
id: string;
|
|
176
|
+
callID: string;
|
|
177
|
+
messageID: string;
|
|
178
|
+
sessionID: string;
|
|
143
179
|
state: ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError;
|
|
144
180
|
tool: string;
|
|
145
181
|
type: 'tool';
|
|
146
182
|
}
|
|
147
183
|
export interface ToolStateCompleted {
|
|
184
|
+
input: {
|
|
185
|
+
[key: string]: unknown;
|
|
186
|
+
};
|
|
148
187
|
metadata: {
|
|
149
188
|
[key: string]: unknown;
|
|
150
189
|
};
|
|
@@ -152,7 +191,6 @@ export interface ToolStateCompleted {
|
|
|
152
191
|
status: 'completed';
|
|
153
192
|
time: ToolStateCompleted.Time;
|
|
154
193
|
title: string;
|
|
155
|
-
input?: unknown;
|
|
156
194
|
}
|
|
157
195
|
export declare namespace ToolStateCompleted {
|
|
158
196
|
interface Time {
|
|
@@ -162,9 +200,11 @@ export declare namespace ToolStateCompleted {
|
|
|
162
200
|
}
|
|
163
201
|
export interface ToolStateError {
|
|
164
202
|
error: string;
|
|
203
|
+
input: {
|
|
204
|
+
[key: string]: unknown;
|
|
205
|
+
};
|
|
165
206
|
status: 'error';
|
|
166
207
|
time: ToolStateError.Time;
|
|
167
|
-
input?: unknown;
|
|
168
208
|
}
|
|
169
209
|
export declare namespace ToolStateError {
|
|
170
210
|
interface Time {
|
|
@@ -189,19 +229,38 @@ export declare namespace ToolStateRunning {
|
|
|
189
229
|
start: number;
|
|
190
230
|
}
|
|
191
231
|
}
|
|
192
|
-
export
|
|
232
|
+
export interface UserMessage {
|
|
233
|
+
id: string;
|
|
234
|
+
role: 'user';
|
|
235
|
+
sessionID: string;
|
|
236
|
+
time: UserMessage.Time;
|
|
237
|
+
}
|
|
238
|
+
export declare namespace UserMessage {
|
|
239
|
+
interface Time {
|
|
240
|
+
created: number;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
193
243
|
export type SessionListResponse = Array<Session>;
|
|
194
244
|
export type SessionDeleteResponse = boolean;
|
|
195
245
|
export type SessionAbortResponse = boolean;
|
|
196
246
|
export type SessionInitResponse = boolean;
|
|
197
|
-
export type SessionMessagesResponse = Array<
|
|
247
|
+
export type SessionMessagesResponse = Array<SessionMessagesResponse.SessionMessagesResponseItem>;
|
|
248
|
+
export declare namespace SessionMessagesResponse {
|
|
249
|
+
interface SessionMessagesResponseItem {
|
|
250
|
+
info: SessionAPI.Message;
|
|
251
|
+
parts: Array<SessionAPI.Part>;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
198
254
|
export type SessionSummarizeResponse = boolean;
|
|
199
255
|
export interface SessionChatParams {
|
|
256
|
+
messageID: string;
|
|
257
|
+
mode: string;
|
|
200
258
|
modelID: string;
|
|
201
|
-
parts: Array<
|
|
259
|
+
parts: Array<FilePart | TextPart>;
|
|
202
260
|
providerID: string;
|
|
203
261
|
}
|
|
204
262
|
export interface SessionInitParams {
|
|
263
|
+
messageID: string;
|
|
205
264
|
modelID: string;
|
|
206
265
|
providerID: string;
|
|
207
266
|
}
|
|
@@ -210,6 +269,6 @@ export interface SessionSummarizeParams {
|
|
|
210
269
|
providerID: string;
|
|
211
270
|
}
|
|
212
271
|
export declare namespace SessionResource {
|
|
213
|
-
export { type AssistantMessage as AssistantMessage, type
|
|
272
|
+
export { type AssistantMessage as AssistantMessage, type FilePart as FilePart, type Message as Message, type Part as Part, type Session as Session, 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
273
|
}
|
|
215
274
|
//# 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,cAAc,GAAG,UAAU,CAAC,gBAAgB,CAAC;IAIjG;;OAEG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,m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nD,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,7 @@ import {
|
|
|
54
65
|
SessionResource,
|
|
55
66
|
SessionSummarizeParams,
|
|
56
67
|
SessionSummarizeResponse,
|
|
68
|
+
StepFinishPart,
|
|
57
69
|
StepStartPart,
|
|
58
70
|
TextPart,
|
|
59
71
|
ToolPart,
|
|
@@ -61,14 +73,14 @@ import {
|
|
|
61
73
|
ToolStateError,
|
|
62
74
|
ToolStatePending,
|
|
63
75
|
ToolStateRunning,
|
|
64
|
-
|
|
76
|
+
UserMessage,
|
|
65
77
|
} from './resources/session';
|
|
66
78
|
import { type Fetch } from './internal/builtin-types';
|
|
67
79
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
68
80
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
69
81
|
import { readEnv } from './internal/utils/env';
|
|
70
82
|
import {
|
|
71
|
-
type LogLevel,
|
|
83
|
+
type LogLevel as ClientLogLevel,
|
|
72
84
|
type Logger,
|
|
73
85
|
formatRequestDetails,
|
|
74
86
|
loggerFor,
|
|
@@ -136,7 +148,7 @@ export interface ClientOptions {
|
|
|
136
148
|
*
|
|
137
149
|
* Defaults to process.env['OPENCODE_LOG'] or 'warn' if it isn't set.
|
|
138
150
|
*/
|
|
139
|
-
logLevel?:
|
|
151
|
+
logLevel?: ClientLogLevel | undefined;
|
|
140
152
|
|
|
141
153
|
/**
|
|
142
154
|
* Set the logger.
|
|
@@ -154,7 +166,7 @@ export class Opencode {
|
|
|
154
166
|
maxRetries: number;
|
|
155
167
|
timeout: number;
|
|
156
168
|
logger: Logger | undefined;
|
|
157
|
-
logLevel:
|
|
169
|
+
logLevel: ClientLogLevel | undefined;
|
|
158
170
|
fetchOptions: MergedRequestInit | undefined;
|
|
159
171
|
|
|
160
172
|
private fetch: Fetch;
|
|
@@ -201,7 +213,7 @@ export class Opencode {
|
|
|
201
213
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
202
214
|
*/
|
|
203
215
|
withOptions(options: Partial<ClientOptions>): this {
|
|
204
|
-
|
|
216
|
+
const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({
|
|
205
217
|
...this._options,
|
|
206
218
|
baseURL: this.baseURL,
|
|
207
219
|
maxRetries: this.maxRetries,
|
|
@@ -212,6 +224,7 @@ export class Opencode {
|
|
|
212
224
|
fetchOptions: this.fetchOptions,
|
|
213
225
|
...options,
|
|
214
226
|
});
|
|
227
|
+
return client;
|
|
215
228
|
}
|
|
216
229
|
|
|
217
230
|
/**
|
|
@@ -357,7 +370,9 @@ export class Opencode {
|
|
|
357
370
|
|
|
358
371
|
await this.prepareOptions(options);
|
|
359
372
|
|
|
360
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
373
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
374
|
+
retryCount: maxRetries - retriesRemaining,
|
|
375
|
+
});
|
|
361
376
|
|
|
362
377
|
await this.prepareRequest(req, { url, options });
|
|
363
378
|
|
|
@@ -435,7 +450,7 @@ export class Opencode {
|
|
|
435
450
|
} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
436
451
|
|
|
437
452
|
if (!response.ok) {
|
|
438
|
-
const shouldRetry = this.shouldRetry(response);
|
|
453
|
+
const shouldRetry = await this.shouldRetry(response);
|
|
439
454
|
if (retriesRemaining && shouldRetry) {
|
|
440
455
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
441
456
|
|
|
@@ -534,7 +549,7 @@ export class Opencode {
|
|
|
534
549
|
}
|
|
535
550
|
}
|
|
536
551
|
|
|
537
|
-
private shouldRetry(response: Response): boolean {
|
|
552
|
+
private async shouldRetry(response: Response): Promise<boolean> {
|
|
538
553
|
// Note this is not a standard header.
|
|
539
554
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
540
555
|
|
|
@@ -611,10 +626,10 @@ export class Opencode {
|
|
|
611
626
|
return sleepSeconds * jitter * 1000;
|
|
612
627
|
}
|
|
613
628
|
|
|
614
|
-
buildRequest(
|
|
629
|
+
async buildRequest(
|
|
615
630
|
inputOptions: FinalRequestOptions,
|
|
616
631
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
617
|
-
): { req: FinalizedRequestInit; url: string; timeout: number } {
|
|
632
|
+
): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> {
|
|
618
633
|
const options = { ...inputOptions };
|
|
619
634
|
const { method, path, query, defaultBaseURL } = options;
|
|
620
635
|
|
|
@@ -622,7 +637,7 @@ export class Opencode {
|
|
|
622
637
|
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
623
638
|
options.timeout = options.timeout ?? this.timeout;
|
|
624
639
|
const { bodyHeaders, body } = this.buildBody({ options });
|
|
625
|
-
const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
640
|
+
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
626
641
|
|
|
627
642
|
const req: FinalizedRequestInit = {
|
|
628
643
|
method,
|
|
@@ -638,7 +653,7 @@ export class Opencode {
|
|
|
638
653
|
return { req, url, timeout: options.timeout };
|
|
639
654
|
}
|
|
640
655
|
|
|
641
|
-
private buildHeaders({
|
|
656
|
+
private async buildHeaders({
|
|
642
657
|
options,
|
|
643
658
|
method,
|
|
644
659
|
bodyHeaders,
|
|
@@ -648,7 +663,7 @@ export class Opencode {
|
|
|
648
663
|
method: HTTPMethod;
|
|
649
664
|
bodyHeaders: HeadersLike;
|
|
650
665
|
retryCount: number;
|
|
651
|
-
}): Headers {
|
|
666
|
+
}): Promise<Headers> {
|
|
652
667
|
let idempotencyHeaders: HeadersLike = {};
|
|
653
668
|
if (this.idempotencyHeader && method !== 'get') {
|
|
654
669
|
if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
|
|
@@ -733,14 +748,14 @@ export class Opencode {
|
|
|
733
748
|
event: API.Event = new API.Event(this);
|
|
734
749
|
app: API.AppResource = new API.AppResource(this);
|
|
735
750
|
find: API.Find = new API.Find(this);
|
|
736
|
-
file: API.
|
|
751
|
+
file: API.FileResource = new API.FileResource(this);
|
|
737
752
|
config: API.ConfigResource = new API.ConfigResource(this);
|
|
738
753
|
session: API.SessionResource = new API.SessionResource(this);
|
|
739
754
|
}
|
|
740
755
|
Opencode.Event = Event;
|
|
741
756
|
Opencode.AppResource = AppResource;
|
|
742
757
|
Opencode.Find = Find;
|
|
743
|
-
Opencode.
|
|
758
|
+
Opencode.FileResource = FileResource;
|
|
744
759
|
Opencode.ConfigResource = ConfigResource;
|
|
745
760
|
Opencode.SessionResource = SessionResource;
|
|
746
761
|
export declare namespace Opencode {
|
|
@@ -748,10 +763,21 @@ export declare namespace Opencode {
|
|
|
748
763
|
|
|
749
764
|
export { Event as Event, type EventListResponse as EventListResponse };
|
|
750
765
|
|
|
751
|
-
export {
|
|
766
|
+
export {
|
|
767
|
+
AppResource as AppResource,
|
|
768
|
+
type App as App,
|
|
769
|
+
type LogLevel as LogLevel,
|
|
770
|
+
type Mode as Mode,
|
|
771
|
+
type AppInitResponse as AppInitResponse,
|
|
772
|
+
type AppLogResponse as AppLogResponse,
|
|
773
|
+
type AppModesResponse as AppModesResponse,
|
|
774
|
+
type AppLogParams as AppLogParams,
|
|
775
|
+
};
|
|
752
776
|
|
|
753
777
|
export {
|
|
754
778
|
Find as Find,
|
|
779
|
+
type Match as Match,
|
|
780
|
+
type Symbol as Symbol,
|
|
755
781
|
type FindFilesResponse as FindFilesResponse,
|
|
756
782
|
type FindSymbolsResponse as FindSymbolsResponse,
|
|
757
783
|
type FindTextResponse as FindTextResponse,
|
|
@@ -761,7 +787,8 @@ export declare namespace Opencode {
|
|
|
761
787
|
};
|
|
762
788
|
|
|
763
789
|
export {
|
|
764
|
-
|
|
790
|
+
FileResource as FileResource,
|
|
791
|
+
type File as File,
|
|
765
792
|
type FileReadResponse as FileReadResponse,
|
|
766
793
|
type FileStatusResponse as FileStatusResponse,
|
|
767
794
|
type FileReadParams as FileReadParams,
|
|
@@ -781,10 +808,11 @@ export declare namespace Opencode {
|
|
|
781
808
|
export {
|
|
782
809
|
SessionResource as SessionResource,
|
|
783
810
|
type AssistantMessage as AssistantMessage,
|
|
784
|
-
type AssistantMessagePart as AssistantMessagePart,
|
|
785
811
|
type FilePart as FilePart,
|
|
786
812
|
type Message as Message,
|
|
813
|
+
type Part as Part,
|
|
787
814
|
type Session as Session,
|
|
815
|
+
type StepFinishPart as StepFinishPart,
|
|
788
816
|
type StepStartPart as StepStartPart,
|
|
789
817
|
type TextPart as TextPart,
|
|
790
818
|
type ToolPart as ToolPart,
|
|
@@ -792,7 +820,7 @@ export declare namespace Opencode {
|
|
|
792
820
|
type ToolStateError as ToolStateError,
|
|
793
821
|
type ToolStatePending as ToolStatePending,
|
|
794
822
|
type ToolStateRunning as ToolStateRunning,
|
|
795
|
-
type
|
|
823
|
+
type UserMessage as UserMessage,
|
|
796
824
|
type SessionListResponse as SessionListResponse,
|
|
797
825
|
type SessionDeleteResponse as SessionDeleteResponse,
|
|
798
826
|
type SessionAbortResponse as SessionAbortResponse,
|
|
@@ -804,6 +832,7 @@ export declare namespace Opencode {
|
|
|
804
832
|
type SessionSummarizeParams as SessionSummarizeParams,
|
|
805
833
|
};
|
|
806
834
|
|
|
835
|
+
export type MessageAbortedError = API.MessageAbortedError;
|
|
807
836
|
export type ProviderAuthError = API.ProviderAuthError;
|
|
808
837
|
export type UnknownError = API.UnknownError;
|
|
809
838
|
}
|
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
|
}
|