@opencode-ai/sdk 0.1.0-alpha.2 → 0.1.0-alpha.20
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 +173 -0
- package/LICENSE +198 -4
- package/README.md +27 -9
- package/client.d.mts +25 -53
- package/client.d.mts.map +1 -1
- package/client.d.ts +25 -53
- package/client.d.ts.map +1 -1
- package/client.js +25 -55
- package/client.js.map +1 -1
- package/client.mjs +25 -55
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts +33 -0
- package/core/streaming.d.mts.map +1 -0
- package/core/streaming.d.ts +33 -0
- package/core/streaming.d.ts.map +1 -0
- package/core/streaming.js +263 -0
- package/core/streaming.js.map +1 -0
- package/core/streaming.mjs +258 -0
- package/core/streaming.mjs.map +1 -0
- package/internal/decoders/line.d.mts +17 -0
- package/internal/decoders/line.d.mts.map +1 -0
- package/internal/decoders/line.d.ts +17 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +113 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +108 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +10 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +10 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/request-options.d.mts +44 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +44 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/tslib.js +6 -6
- package/internal/types.d.mts +8 -6
- package/internal/types.d.mts.map +1 -1
- package/internal/types.d.ts +8 -6
- package/internal/types.d.ts.map +1 -1
- package/internal/uploads.js +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/log.js +1 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.d.mts.map +1 -1
- package/internal/utils/path.d.ts.map +1 -1
- package/internal/utils/path.js +26 -5
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +26 -5
- package/internal/utils/path.mjs.map +1 -1
- package/package.json +13 -3
- package/resources/app.d.mts +130 -0
- package/resources/app.d.mts.map +1 -0
- package/resources/app.d.ts +130 -0
- package/resources/app.d.ts.map +1 -0
- package/resources/app.js +39 -0
- package/resources/app.js.map +1 -0
- package/resources/app.mjs +35 -0
- package/resources/app.mjs.map +1 -0
- package/resources/config.d.mts +344 -0
- package/resources/config.d.mts.map +1 -0
- package/resources/config.d.ts +344 -0
- package/resources/config.d.ts.map +1 -0
- package/resources/{config-get.js → config.js} +6 -6
- package/resources/config.js.map +1 -0
- package/resources/{config-get.mjs → config.mjs} +4 -4
- package/resources/config.mjs.map +1 -0
- package/resources/event.d.mts +82 -29
- package/resources/event.d.mts.map +1 -1
- package/resources/event.d.ts +82 -29
- package/resources/event.d.ts.map +1 -1
- package/resources/event.js +1 -1
- package/resources/event.js.map +1 -1
- package/resources/event.mjs +1 -1
- package/resources/event.mjs.map +1 -1
- package/resources/file.d.mts +31 -0
- package/resources/file.d.mts.map +1 -0
- package/resources/file.d.ts +31 -0
- package/resources/file.d.ts.map +1 -0
- package/resources/file.js +21 -0
- package/resources/file.js.map +1 -0
- package/resources/file.mjs +17 -0
- package/resources/file.mjs.map +1 -0
- package/resources/find.d.mts +85 -0
- package/resources/find.d.mts.map +1 -0
- package/resources/find.d.ts +85 -0
- package/resources/find.d.ts.map +1 -0
- package/resources/find.js +27 -0
- package/resources/find.js.map +1 -0
- package/resources/find.mjs +23 -0
- package/resources/find.mjs.map +1 -0
- package/resources/index.d.mts +6 -16
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +6 -16
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +13 -33
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +6 -16
- package/resources/index.mjs.map +1 -1
- package/resources/session.d.mts +272 -0
- package/resources/session.d.mts.map +1 -0
- package/resources/session.d.ts +272 -0
- package/resources/session.d.ts.map +1 -0
- package/resources/session.js +70 -0
- package/resources/session.js.map +1 -0
- package/resources/session.mjs +66 -0
- package/resources/session.mjs.map +1 -0
- package/resources/shared.d.mts +24 -0
- package/resources/shared.d.mts.map +1 -0
- package/resources/shared.d.ts +24 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/shared.js +4 -0
- package/resources/shared.js.map +1 -0
- package/resources/shared.mjs +3 -0
- package/resources/shared.mjs.map +1 -0
- package/src/client.ts +145 -128
- package/src/core/streaming.ts +315 -0
- package/src/internal/decoders/line.ts +135 -0
- package/src/internal/parse.ts +14 -0
- package/src/internal/request-options.ts +55 -0
- package/src/internal/types.ts +9 -6
- package/src/internal/uploads.ts +1 -1
- package/src/internal/utils/log.ts +1 -1
- package/src/internal/utils/path.ts +32 -7
- package/src/resources/app.ts +196 -0
- package/src/resources/config.ts +431 -0
- package/src/resources/event.ts +119 -39
- package/src/resources/file.ts +52 -0
- package/src/resources/find.ts +133 -0
- package/src/resources/index.ts +65 -32
- package/src/resources/session.ts +457 -0
- package/src/resources/shared.ts +33 -0
- package/src/streaming.ts +2 -0
- package/src/version.ts +1 -1
- package/streaming.d.mts +2 -0
- package/streaming.d.mts.map +1 -0
- package/streaming.d.ts +2 -0
- package/streaming.d.ts.map +1 -0
- package/streaming.js +6 -0
- package/streaming.js.map +1 -0
- package/streaming.mjs +2 -0
- package/streaming.mjs.map +1 -0
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/resources/app-info.d.mts +0 -31
- package/resources/app-info.d.mts.map +0 -1
- package/resources/app-info.d.ts +0 -31
- package/resources/app-info.d.ts.map +0 -1
- package/resources/app-info.js +0 -15
- package/resources/app-info.js.map +0 -1
- package/resources/app-info.mjs +0 -11
- package/resources/app-info.mjs.map +0 -1
- package/resources/app-initialize.d.mts +0 -14
- package/resources/app-initialize.d.mts.map +0 -1
- package/resources/app-initialize.d.ts +0 -14
- package/resources/app-initialize.d.ts.map +0 -1
- package/resources/app-initialize.js +0 -15
- package/resources/app-initialize.js.map +0 -1
- package/resources/app-initialize.mjs +0 -11
- package/resources/app-initialize.mjs.map +0 -1
- package/resources/config-get.d.mts +0 -236
- package/resources/config-get.d.mts.map +0 -1
- package/resources/config-get.d.ts +0 -236
- package/resources/config-get.d.ts.map +0 -1
- package/resources/config-get.js.map +0 -1
- package/resources/config-get.mjs.map +0 -1
- package/resources/file-search.d.mts +0 -17
- package/resources/file-search.d.mts.map +0 -1
- package/resources/file-search.d.ts +0 -17
- package/resources/file-search.d.ts.map +0 -1
- package/resources/file-search.js +0 -15
- package/resources/file-search.js.map +0 -1
- package/resources/file-search.mjs +0 -11
- package/resources/file-search.mjs.map +0 -1
- package/resources/installation-info.d.mts +0 -17
- package/resources/installation-info.d.mts.map +0 -1
- package/resources/installation-info.d.ts +0 -17
- package/resources/installation-info.d.ts.map +0 -1
- package/resources/installation-info.js +0 -15
- package/resources/installation-info.js.map +0 -1
- package/resources/installation-info.mjs +0 -11
- package/resources/installation-info.mjs.map +0 -1
- package/resources/path-get.d.mts +0 -19
- package/resources/path-get.d.mts.map +0 -1
- package/resources/path-get.d.ts +0 -19
- package/resources/path-get.d.ts.map +0 -1
- package/resources/path-get.js +0 -15
- package/resources/path-get.js.map +0 -1
- package/resources/path-get.mjs +0 -11
- package/resources/path-get.mjs.map +0 -1
- package/resources/provider-list.d.mts +0 -58
- package/resources/provider-list.d.mts.map +0 -1
- package/resources/provider-list.d.ts +0 -58
- package/resources/provider-list.d.ts.map +0 -1
- package/resources/provider-list.js +0 -15
- package/resources/provider-list.js.map +0 -1
- package/resources/provider-list.mjs +0 -11
- package/resources/provider-list.mjs.map +0 -1
- package/resources/session-abort.d.mts +0 -17
- package/resources/session-abort.d.mts.map +0 -1
- package/resources/session-abort.d.ts +0 -17
- package/resources/session-abort.d.ts.map +0 -1
- package/resources/session-abort.js +0 -15
- package/resources/session-abort.js.map +0 -1
- package/resources/session-abort.mjs +0 -11
- package/resources/session-abort.mjs.map +0 -1
- package/resources/session-chat.d.mts +0 -160
- package/resources/session-chat.d.mts.map +0 -1
- package/resources/session-chat.d.ts +0 -160
- package/resources/session-chat.d.ts.map +0 -1
- package/resources/session-chat.js +0 -15
- package/resources/session-chat.js.map +0 -1
- package/resources/session-chat.mjs +0 -11
- package/resources/session-chat.mjs.map +0 -1
- package/resources/session-create.d.mts +0 -30
- package/resources/session-create.d.mts.map +0 -1
- package/resources/session-create.d.ts +0 -30
- package/resources/session-create.d.ts.map +0 -1
- package/resources/session-create.js +0 -15
- package/resources/session-create.js.map +0 -1
- package/resources/session-create.mjs +0 -11
- package/resources/session-create.mjs.map +0 -1
- package/resources/session-initialize.d.mts +0 -19
- package/resources/session-initialize.d.mts.map +0 -1
- package/resources/session-initialize.d.ts +0 -19
- package/resources/session-initialize.d.ts.map +0 -1
- package/resources/session-initialize.js +0 -15
- package/resources/session-initialize.js.map +0 -1
- package/resources/session-initialize.mjs +0 -11
- package/resources/session-initialize.mjs.map +0 -1
- package/resources/session-list.d.mts +0 -15
- package/resources/session-list.d.mts.map +0 -1
- package/resources/session-list.d.ts +0 -15
- package/resources/session-list.d.ts.map +0 -1
- package/resources/session-list.js +0 -15
- package/resources/session-list.js.map +0 -1
- package/resources/session-list.mjs +0 -11
- package/resources/session-list.mjs.map +0 -1
- package/resources/session-messages.d.mts +0 -18
- package/resources/session-messages.d.mts.map +0 -1
- package/resources/session-messages.d.ts +0 -18
- package/resources/session-messages.d.ts.map +0 -1
- package/resources/session-messages.js +0 -15
- package/resources/session-messages.js.map +0 -1
- package/resources/session-messages.mjs +0 -11
- package/resources/session-messages.mjs.map +0 -1
- package/resources/session-share.d.mts +0 -17
- package/resources/session-share.d.mts.map +0 -1
- package/resources/session-share.d.ts +0 -17
- package/resources/session-share.d.ts.map +0 -1
- package/resources/session-share.js +0 -15
- package/resources/session-share.js.map +0 -1
- package/resources/session-share.mjs +0 -11
- package/resources/session-share.mjs.map +0 -1
- package/resources/session-summarize.d.mts +0 -19
- package/resources/session-summarize.d.mts.map +0 -1
- package/resources/session-summarize.d.ts +0 -19
- package/resources/session-summarize.d.ts.map +0 -1
- package/resources/session-summarize.js +0 -15
- package/resources/session-summarize.js.map +0 -1
- package/resources/session-summarize.mjs +0 -11
- package/resources/session-summarize.mjs.map +0 -1
- package/resources/session-unshare.d.mts +0 -17
- package/resources/session-unshare.d.mts.map +0 -1
- package/resources/session-unshare.d.ts +0 -17
- package/resources/session-unshare.d.ts.map +0 -1
- package/resources/session-unshare.js +0 -15
- package/resources/session-unshare.js.map +0 -1
- package/resources/session-unshare.mjs +0 -11
- package/resources/session-unshare.mjs.map +0 -1
- package/src/resources/app-info.ts +0 -46
- package/src/resources/app-initialize.ts +0 -20
- package/src/resources/config-get.ts +0 -294
- package/src/resources/file-search.ts +0 -27
- package/src/resources/installation-info.ts +0 -24
- package/src/resources/path-get.ts +0 -28
- package/src/resources/provider-list.ts +0 -80
- package/src/resources/session-abort.ts +0 -27
- package/src/resources/session-chat.ts +0 -250
- package/src/resources/session-create.ts +0 -44
- package/src/resources/session-initialize.ts +0 -34
- package/src/resources/session-list.ts +0 -21
- package/src/resources/session-messages.ts +0 -31
- package/src/resources/session-share.ts +0 -23
- package/src/resources/session-summarize.ts +0 -34
- package/src/resources/session-unshare.ts +0 -26
package/src/client.ts
CHANGED
|
@@ -16,48 +16,74 @@ 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 { AppInfo, AppInfoCreateResponse } from './resources/app-info';
|
|
20
|
-
import { AppInitialize, AppInitializeInitializeResponse } from './resources/app-initialize';
|
|
21
|
-
import { ConfigGet, ConfigGetRetrieveResponse } from './resources/config-get';
|
|
22
|
-
import { Event, EventListResponse } from './resources/event';
|
|
23
|
-
import { FileSearch, FileSearchSearchParams, FileSearchSearchResponse } from './resources/file-search';
|
|
24
|
-
import { InstallationInfo, InstallationInfoCreateResponse } from './resources/installation-info';
|
|
25
|
-
import { PathGet, PathGetCreateResponse } from './resources/path-get';
|
|
26
|
-
import { ProviderList, ProviderListCreateResponse } from './resources/provider-list';
|
|
27
|
-
import { SessionAbort, SessionAbortAbortParams, SessionAbortAbortResponse } from './resources/session-abort';
|
|
28
19
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
App,
|
|
21
|
+
AppInitResponse,
|
|
22
|
+
AppLogParams,
|
|
23
|
+
AppLogResponse,
|
|
24
|
+
AppModesResponse,
|
|
25
|
+
AppProvidersResponse,
|
|
26
|
+
AppResource,
|
|
27
|
+
LogLevel,
|
|
28
|
+
Mode,
|
|
29
|
+
Model,
|
|
30
|
+
Provider,
|
|
31
|
+
} from './resources/app';
|
|
37
32
|
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
Config,
|
|
34
|
+
ConfigResource,
|
|
35
|
+
KeybindsConfig,
|
|
36
|
+
LayoutConfig,
|
|
37
|
+
McpLocalConfig,
|
|
38
|
+
McpRemoteConfig,
|
|
39
|
+
ModeConfig,
|
|
40
|
+
} from './resources/config';
|
|
41
|
+
import { Event, EventListResponse } from './resources/event';
|
|
42
|
+
import { File, FileReadParams, FileReadResponse, FileResource, FileStatusResponse } from './resources/file';
|
|
43
43
|
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
Find,
|
|
45
|
+
FindFilesParams,
|
|
46
|
+
FindFilesResponse,
|
|
47
|
+
FindSymbolsParams,
|
|
48
|
+
FindSymbolsResponse,
|
|
49
|
+
FindTextParams,
|
|
50
|
+
FindTextResponse,
|
|
51
|
+
Match,
|
|
52
|
+
Symbol,
|
|
53
|
+
} from './resources/find';
|
|
49
54
|
import {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
AssistantMessage,
|
|
56
|
+
FilePart,
|
|
57
|
+
Message,
|
|
58
|
+
Part,
|
|
59
|
+
Session,
|
|
60
|
+
SessionAbortResponse,
|
|
61
|
+
SessionChatParams,
|
|
62
|
+
SessionDeleteResponse,
|
|
63
|
+
SessionInitParams,
|
|
64
|
+
SessionInitResponse,
|
|
65
|
+
SessionListResponse,
|
|
66
|
+
SessionMessagesResponse,
|
|
67
|
+
SessionResource,
|
|
68
|
+
SessionSummarizeParams,
|
|
69
|
+
SessionSummarizeResponse,
|
|
70
|
+
SnapshotPart,
|
|
71
|
+
StepFinishPart,
|
|
72
|
+
StepStartPart,
|
|
73
|
+
TextPart,
|
|
74
|
+
ToolPart,
|
|
75
|
+
ToolStateCompleted,
|
|
76
|
+
ToolStateError,
|
|
77
|
+
ToolStatePending,
|
|
78
|
+
ToolStateRunning,
|
|
79
|
+
UserMessage,
|
|
80
|
+
} from './resources/session';
|
|
55
81
|
import { type Fetch } from './internal/builtin-types';
|
|
56
82
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
57
83
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
58
84
|
import { readEnv } from './internal/utils/env';
|
|
59
85
|
import {
|
|
60
|
-
type LogLevel,
|
|
86
|
+
type LogLevel as ClientLogLevel,
|
|
61
87
|
type Logger,
|
|
62
88
|
formatRequestDetails,
|
|
63
89
|
loggerFor,
|
|
@@ -79,6 +105,8 @@ export interface ClientOptions {
|
|
|
79
105
|
*
|
|
80
106
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
81
107
|
* much longer than this timeout before the promise succeeds or fails.
|
|
108
|
+
*
|
|
109
|
+
* @unit milliseconds
|
|
82
110
|
*/
|
|
83
111
|
timeout?: number | undefined;
|
|
84
112
|
/**
|
|
@@ -123,7 +151,7 @@ export interface ClientOptions {
|
|
|
123
151
|
*
|
|
124
152
|
* Defaults to process.env['OPENCODE_LOG'] or 'warn' if it isn't set.
|
|
125
153
|
*/
|
|
126
|
-
logLevel?:
|
|
154
|
+
logLevel?: ClientLogLevel | undefined;
|
|
127
155
|
|
|
128
156
|
/**
|
|
129
157
|
* Set the logger.
|
|
@@ -141,7 +169,7 @@ export class Opencode {
|
|
|
141
169
|
maxRetries: number;
|
|
142
170
|
timeout: number;
|
|
143
171
|
logger: Logger | undefined;
|
|
144
|
-
logLevel:
|
|
172
|
+
logLevel: ClientLogLevel | undefined;
|
|
145
173
|
fetchOptions: MergedRequestInit | undefined;
|
|
146
174
|
|
|
147
175
|
private fetch: Fetch;
|
|
@@ -188,7 +216,7 @@ export class Opencode {
|
|
|
188
216
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
189
217
|
*/
|
|
190
218
|
withOptions(options: Partial<ClientOptions>): this {
|
|
191
|
-
|
|
219
|
+
const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({
|
|
192
220
|
...this._options,
|
|
193
221
|
baseURL: this.baseURL,
|
|
194
222
|
maxRetries: this.maxRetries,
|
|
@@ -199,6 +227,7 @@ export class Opencode {
|
|
|
199
227
|
fetchOptions: this.fetchOptions,
|
|
200
228
|
...options,
|
|
201
229
|
});
|
|
230
|
+
return client;
|
|
202
231
|
}
|
|
203
232
|
|
|
204
233
|
/**
|
|
@@ -344,7 +373,9 @@ export class Opencode {
|
|
|
344
373
|
|
|
345
374
|
await this.prepareOptions(options);
|
|
346
375
|
|
|
347
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
376
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
377
|
+
retryCount: maxRetries - retriesRemaining,
|
|
378
|
+
});
|
|
348
379
|
|
|
349
380
|
await this.prepareRequest(req, { url, options });
|
|
350
381
|
|
|
@@ -422,7 +453,7 @@ export class Opencode {
|
|
|
422
453
|
} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
423
454
|
|
|
424
455
|
if (!response.ok) {
|
|
425
|
-
const shouldRetry = this.shouldRetry(response);
|
|
456
|
+
const shouldRetry = await this.shouldRetry(response);
|
|
426
457
|
if (retriesRemaining && shouldRetry) {
|
|
427
458
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
428
459
|
|
|
@@ -521,7 +552,7 @@ export class Opencode {
|
|
|
521
552
|
}
|
|
522
553
|
}
|
|
523
554
|
|
|
524
|
-
private shouldRetry(response: Response): boolean {
|
|
555
|
+
private async shouldRetry(response: Response): Promise<boolean> {
|
|
525
556
|
// Note this is not a standard header.
|
|
526
557
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
527
558
|
|
|
@@ -598,10 +629,10 @@ export class Opencode {
|
|
|
598
629
|
return sleepSeconds * jitter * 1000;
|
|
599
630
|
}
|
|
600
631
|
|
|
601
|
-
buildRequest(
|
|
632
|
+
async buildRequest(
|
|
602
633
|
inputOptions: FinalRequestOptions,
|
|
603
634
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
604
|
-
): { req: FinalizedRequestInit; url: string; timeout: number } {
|
|
635
|
+
): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> {
|
|
605
636
|
const options = { ...inputOptions };
|
|
606
637
|
const { method, path, query, defaultBaseURL } = options;
|
|
607
638
|
|
|
@@ -609,7 +640,7 @@ export class Opencode {
|
|
|
609
640
|
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
610
641
|
options.timeout = options.timeout ?? this.timeout;
|
|
611
642
|
const { bodyHeaders, body } = this.buildBody({ options });
|
|
612
|
-
const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
643
|
+
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
613
644
|
|
|
614
645
|
const req: FinalizedRequestInit = {
|
|
615
646
|
method,
|
|
@@ -625,7 +656,7 @@ export class Opencode {
|
|
|
625
656
|
return { req, url, timeout: options.timeout };
|
|
626
657
|
}
|
|
627
658
|
|
|
628
|
-
private buildHeaders({
|
|
659
|
+
private async buildHeaders({
|
|
629
660
|
options,
|
|
630
661
|
method,
|
|
631
662
|
bodyHeaders,
|
|
@@ -635,7 +666,7 @@ export class Opencode {
|
|
|
635
666
|
method: HTTPMethod;
|
|
636
667
|
bodyHeaders: HeadersLike;
|
|
637
668
|
retryCount: number;
|
|
638
|
-
}): Headers {
|
|
669
|
+
}): Promise<Headers> {
|
|
639
670
|
let idempotencyHeaders: HeadersLike = {};
|
|
640
671
|
if (this.idempotencyHeader && method !== 'get') {
|
|
641
672
|
if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
|
|
@@ -718,110 +749,96 @@ export class Opencode {
|
|
|
718
749
|
static toFile = Uploads.toFile;
|
|
719
750
|
|
|
720
751
|
event: API.Event = new API.Event(this);
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
sessionCreate: API.SessionCreate = new API.SessionCreate(this);
|
|
727
|
-
sessionShare: API.SessionShare = new API.SessionShare(this);
|
|
728
|
-
sessionUnshare: API.SessionUnshare = new API.SessionUnshare(this);
|
|
729
|
-
sessionMessages: API.SessionMessages = new API.SessionMessages(this);
|
|
730
|
-
sessionList: API.SessionList = new API.SessionList(this);
|
|
731
|
-
sessionAbort: API.SessionAbort = new API.SessionAbort(this);
|
|
732
|
-
sessionSummarize: API.SessionSummarize = new API.SessionSummarize(this);
|
|
733
|
-
sessionChat: API.SessionChat = new API.SessionChat(this);
|
|
734
|
-
providerList: API.ProviderList = new API.ProviderList(this);
|
|
735
|
-
fileSearch: API.FileSearch = new API.FileSearch(this);
|
|
736
|
-
installationInfo: API.InstallationInfo = new API.InstallationInfo(this);
|
|
752
|
+
app: API.AppResource = new API.AppResource(this);
|
|
753
|
+
find: API.Find = new API.Find(this);
|
|
754
|
+
file: API.FileResource = new API.FileResource(this);
|
|
755
|
+
config: API.ConfigResource = new API.ConfigResource(this);
|
|
756
|
+
session: API.SessionResource = new API.SessionResource(this);
|
|
737
757
|
}
|
|
738
758
|
Opencode.Event = Event;
|
|
739
|
-
Opencode.
|
|
740
|
-
Opencode.
|
|
741
|
-
Opencode.
|
|
742
|
-
Opencode.
|
|
743
|
-
Opencode.
|
|
744
|
-
Opencode.SessionCreate = SessionCreate;
|
|
745
|
-
Opencode.SessionShare = SessionShare;
|
|
746
|
-
Opencode.SessionUnshare = SessionUnshare;
|
|
747
|
-
Opencode.SessionMessages = SessionMessages;
|
|
748
|
-
Opencode.SessionList = SessionList;
|
|
749
|
-
Opencode.SessionAbort = SessionAbort;
|
|
750
|
-
Opencode.SessionSummarize = SessionSummarize;
|
|
751
|
-
Opencode.SessionChat = SessionChat;
|
|
752
|
-
Opencode.ProviderList = ProviderList;
|
|
753
|
-
Opencode.FileSearch = FileSearch;
|
|
754
|
-
Opencode.InstallationInfo = InstallationInfo;
|
|
759
|
+
Opencode.AppResource = AppResource;
|
|
760
|
+
Opencode.Find = Find;
|
|
761
|
+
Opencode.FileResource = FileResource;
|
|
762
|
+
Opencode.ConfigResource = ConfigResource;
|
|
763
|
+
Opencode.SessionResource = SessionResource;
|
|
755
764
|
export declare namespace Opencode {
|
|
756
765
|
export type RequestOptions = Opts.RequestOptions;
|
|
757
766
|
|
|
758
767
|
export { Event as Event, type EventListResponse as EventListResponse };
|
|
759
768
|
|
|
760
|
-
export { AppInfo as AppInfo, type AppInfoCreateResponse as AppInfoCreateResponse };
|
|
761
|
-
|
|
762
|
-
export { ConfigGet as ConfigGet, type ConfigGetRetrieveResponse as ConfigGetRetrieveResponse };
|
|
763
|
-
|
|
764
|
-
export {
|
|
765
|
-
AppInitialize as AppInitialize,
|
|
766
|
-
type AppInitializeInitializeResponse as AppInitializeInitializeResponse,
|
|
767
|
-
};
|
|
768
|
-
|
|
769
|
-
export {
|
|
770
|
-
SessionInitialize as SessionInitialize,
|
|
771
|
-
type SessionInitializeCreateResponse as SessionInitializeCreateResponse,
|
|
772
|
-
type SessionInitializeCreateParams as SessionInitializeCreateParams,
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
export { PathGet as PathGet, type PathGetCreateResponse as PathGetCreateResponse };
|
|
776
|
-
|
|
777
|
-
export { SessionCreate as SessionCreate, type SessionInfo as SessionInfo };
|
|
778
|
-
|
|
779
|
-
export { SessionShare as SessionShare, type SessionShareCreateParams as SessionShareCreateParams };
|
|
780
|
-
|
|
781
769
|
export {
|
|
782
|
-
|
|
783
|
-
type
|
|
770
|
+
AppResource as AppResource,
|
|
771
|
+
type App as App,
|
|
772
|
+
type LogLevel as LogLevel,
|
|
773
|
+
type Mode as Mode,
|
|
774
|
+
type Model as Model,
|
|
775
|
+
type Provider as Provider,
|
|
776
|
+
type AppInitResponse as AppInitResponse,
|
|
777
|
+
type AppLogResponse as AppLogResponse,
|
|
778
|
+
type AppModesResponse as AppModesResponse,
|
|
779
|
+
type AppProvidersResponse as AppProvidersResponse,
|
|
780
|
+
type AppLogParams as AppLogParams,
|
|
784
781
|
};
|
|
785
782
|
|
|
786
783
|
export {
|
|
787
|
-
|
|
788
|
-
type
|
|
789
|
-
type
|
|
784
|
+
Find as Find,
|
|
785
|
+
type Match as Match,
|
|
786
|
+
type Symbol as Symbol,
|
|
787
|
+
type FindFilesResponse as FindFilesResponse,
|
|
788
|
+
type FindSymbolsResponse as FindSymbolsResponse,
|
|
789
|
+
type FindTextResponse as FindTextResponse,
|
|
790
|
+
type FindFilesParams as FindFilesParams,
|
|
791
|
+
type FindSymbolsParams as FindSymbolsParams,
|
|
792
|
+
type FindTextParams as FindTextParams,
|
|
790
793
|
};
|
|
791
794
|
|
|
792
|
-
export { SessionList as SessionList, type SessionListCreateResponse as SessionListCreateResponse };
|
|
793
|
-
|
|
794
795
|
export {
|
|
795
|
-
|
|
796
|
-
type
|
|
797
|
-
type
|
|
796
|
+
FileResource as FileResource,
|
|
797
|
+
type File as File,
|
|
798
|
+
type FileReadResponse as FileReadResponse,
|
|
799
|
+
type FileStatusResponse as FileStatusResponse,
|
|
800
|
+
type FileReadParams as FileReadParams,
|
|
798
801
|
};
|
|
799
802
|
|
|
800
803
|
export {
|
|
801
|
-
|
|
802
|
-
type
|
|
803
|
-
type
|
|
804
|
+
ConfigResource as ConfigResource,
|
|
805
|
+
type Config as Config,
|
|
806
|
+
type KeybindsConfig as KeybindsConfig,
|
|
807
|
+
type LayoutConfig as LayoutConfig,
|
|
808
|
+
type McpLocalConfig as McpLocalConfig,
|
|
809
|
+
type McpRemoteConfig as McpRemoteConfig,
|
|
810
|
+
type ModeConfig as ModeConfig,
|
|
804
811
|
};
|
|
805
812
|
|
|
806
813
|
export {
|
|
807
|
-
|
|
808
|
-
type
|
|
809
|
-
type
|
|
810
|
-
type
|
|
811
|
-
type
|
|
812
|
-
type
|
|
814
|
+
SessionResource as SessionResource,
|
|
815
|
+
type AssistantMessage as AssistantMessage,
|
|
816
|
+
type FilePart as FilePart,
|
|
817
|
+
type Message as Message,
|
|
818
|
+
type Part as Part,
|
|
819
|
+
type Session as Session,
|
|
820
|
+
type SnapshotPart as SnapshotPart,
|
|
821
|
+
type StepFinishPart as StepFinishPart,
|
|
822
|
+
type StepStartPart as StepStartPart,
|
|
823
|
+
type TextPart as TextPart,
|
|
824
|
+
type ToolPart as ToolPart,
|
|
825
|
+
type ToolStateCompleted as ToolStateCompleted,
|
|
826
|
+
type ToolStateError as ToolStateError,
|
|
827
|
+
type ToolStatePending as ToolStatePending,
|
|
828
|
+
type ToolStateRunning as ToolStateRunning,
|
|
829
|
+
type UserMessage as UserMessage,
|
|
830
|
+
type SessionListResponse as SessionListResponse,
|
|
831
|
+
type SessionDeleteResponse as SessionDeleteResponse,
|
|
832
|
+
type SessionAbortResponse as SessionAbortResponse,
|
|
833
|
+
type SessionInitResponse as SessionInitResponse,
|
|
834
|
+
type SessionMessagesResponse as SessionMessagesResponse,
|
|
835
|
+
type SessionSummarizeResponse as SessionSummarizeResponse,
|
|
836
|
+
type SessionChatParams as SessionChatParams,
|
|
837
|
+
type SessionInitParams as SessionInitParams,
|
|
838
|
+
type SessionSummarizeParams as SessionSummarizeParams,
|
|
813
839
|
};
|
|
814
840
|
|
|
815
|
-
export
|
|
816
|
-
|
|
817
|
-
export
|
|
818
|
-
FileSearch as FileSearch,
|
|
819
|
-
type FileSearchSearchResponse as FileSearchSearchResponse,
|
|
820
|
-
type FileSearchSearchParams as FileSearchSearchParams,
|
|
821
|
-
};
|
|
822
|
-
|
|
823
|
-
export {
|
|
824
|
-
InstallationInfo as InstallationInfo,
|
|
825
|
-
type InstallationInfoCreateResponse as InstallationInfoCreateResponse,
|
|
826
|
-
};
|
|
841
|
+
export type MessageAbortedError = API.MessageAbortedError;
|
|
842
|
+
export type ProviderAuthError = API.ProviderAuthError;
|
|
843
|
+
export type UnknownError = API.UnknownError;
|
|
827
844
|
}
|