@opencode-ai/sdk 0.1.0-alpha.2 → 0.1.0-alpha.21
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 +200 -0
- package/README.md +27 -9
- package/client.d.mts +25 -50
- package/client.d.mts.map +1 -1
- package/client.d.ts +25 -50
- package/client.d.ts.map +1 -1
- package/client.js +28 -55
- package/client.js.map +1 -1
- package/client.mjs +28 -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 +12 -2
- package/resources/app.d.mts +127 -0
- package/resources/app.d.mts.map +1 -0
- package/resources/app.d.ts +127 -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 +391 -0
- package/resources/config.d.mts.map +1 -0
- package/resources/config.d.ts +391 -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 +104 -32
- package/resources/event.d.mts.map +1 -1
- package/resources/event.d.ts +104 -32
- 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 +87 -0
- package/resources/find.d.mts.map +1 -0
- package/resources/find.d.ts +87 -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 +7 -16
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +7 -16
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +15 -33
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +7 -16
- package/resources/index.mjs.map +1 -1
- package/resources/session.d.mts +357 -0
- package/resources/session.d.mts.map +1 -0
- package/resources/session.d.ts +357 -0
- package/resources/session.d.ts.map +1 -0
- package/resources/session.js +82 -0
- package/resources/session.js.map +1 -0
- package/resources/session.mjs +78 -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/resources/tui.d.mts +22 -0
- package/resources/tui.d.mts.map +1 -0
- package/resources/tui.d.ts +22 -0
- package/resources/tui.d.ts.map +1 -0
- package/resources/tui.js +21 -0
- package/resources/tui.js.map +1 -0
- package/resources/tui.mjs +17 -0
- package/resources/tui.mjs.map +1 -0
- package/src/client.ts +157 -122
- 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 +192 -0
- package/src/resources/config.ts +492 -0
- package/src/resources/event.ts +147 -39
- package/src/resources/file.ts +52 -0
- package/src/resources/find.ts +134 -0
- package/src/resources/index.ts +74 -31
- package/src/resources/session.ts +605 -0
- package/src/resources/shared.ts +33 -0
- package/src/resources/tui.ts +37 -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/resources/tui.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Tui = void 0;
|
|
5
|
+
const resource_1 = require("../core/resource.js");
|
|
6
|
+
class Tui extends resource_1.APIResource {
|
|
7
|
+
/**
|
|
8
|
+
* Append prompt to the TUI
|
|
9
|
+
*/
|
|
10
|
+
appendPrompt(body, options) {
|
|
11
|
+
return this._client.post('/tui/append-prompt', { body, ...options });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Open the help dialog
|
|
15
|
+
*/
|
|
16
|
+
openHelp(options) {
|
|
17
|
+
return this._client.post('/tui/open-help', options);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.Tui = Tui;
|
|
21
|
+
//# sourceMappingURL=tui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../src/resources/tui.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,MAAa,GAAI,SAAQ,sBAAW;IAClC;;OAEG;IACH,YAAY,CAAC,IAA2B,EAAE,OAAwB;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAwB;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;CACF;AAdD,kBAcC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../core/resource.mjs";
|
|
3
|
+
export class Tui extends APIResource {
|
|
4
|
+
/**
|
|
5
|
+
* Append prompt to the TUI
|
|
6
|
+
*/
|
|
7
|
+
appendPrompt(body, options) {
|
|
8
|
+
return this._client.post('/tui/append-prompt', { body, ...options });
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Open the help dialog
|
|
12
|
+
*/
|
|
13
|
+
openHelp(options) {
|
|
14
|
+
return this._client.post('/tui/open-help', options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=tui.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.mjs","sourceRoot":"","sources":["../src/resources/tui.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB,MAAM,OAAO,GAAI,SAAQ,WAAW;IAClC;;OAEG;IACH,YAAY,CAAC,IAA2B,EAAE,OAAwB;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAwB;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;CACF"}
|
package/src/client.ts
CHANGED
|
@@ -16,42 +16,73 @@ 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
|
+
Mode,
|
|
28
|
+
Model,
|
|
29
|
+
Provider,
|
|
30
|
+
} from './resources/app';
|
|
37
31
|
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
Config,
|
|
33
|
+
ConfigResource,
|
|
34
|
+
KeybindsConfig,
|
|
35
|
+
McpLocalConfig,
|
|
36
|
+
McpRemoteConfig,
|
|
37
|
+
ModeConfig,
|
|
38
|
+
} from './resources/config';
|
|
39
|
+
import { Event, EventListResponse } from './resources/event';
|
|
40
|
+
import { File, FileReadParams, FileReadResponse, FileResource, FileStatusResponse } from './resources/file';
|
|
43
41
|
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
Find,
|
|
43
|
+
FindFilesParams,
|
|
44
|
+
FindFilesResponse,
|
|
45
|
+
FindSymbolsParams,
|
|
46
|
+
FindSymbolsResponse,
|
|
47
|
+
FindTextParams,
|
|
48
|
+
FindTextResponse,
|
|
49
|
+
Symbol,
|
|
50
|
+
} from './resources/find';
|
|
49
51
|
import {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
AssistantMessage,
|
|
53
|
+
FilePart,
|
|
54
|
+
FilePartInput,
|
|
55
|
+
FilePartSource,
|
|
56
|
+
FilePartSourceText,
|
|
57
|
+
FileSource,
|
|
58
|
+
Message,
|
|
59
|
+
Part,
|
|
60
|
+
Session,
|
|
61
|
+
SessionAbortResponse,
|
|
62
|
+
SessionChatParams,
|
|
63
|
+
SessionDeleteResponse,
|
|
64
|
+
SessionInitParams,
|
|
65
|
+
SessionInitResponse,
|
|
66
|
+
SessionListResponse,
|
|
67
|
+
SessionMessagesResponse,
|
|
68
|
+
SessionResource,
|
|
69
|
+
SessionRevertParams,
|
|
70
|
+
SessionSummarizeParams,
|
|
71
|
+
SessionSummarizeResponse,
|
|
72
|
+
SnapshotPart,
|
|
73
|
+
StepFinishPart,
|
|
74
|
+
StepStartPart,
|
|
75
|
+
SymbolSource,
|
|
76
|
+
TextPart,
|
|
77
|
+
TextPartInput,
|
|
78
|
+
ToolPart,
|
|
79
|
+
ToolStateCompleted,
|
|
80
|
+
ToolStateError,
|
|
81
|
+
ToolStatePending,
|
|
82
|
+
ToolStateRunning,
|
|
83
|
+
UserMessage,
|
|
84
|
+
} from './resources/session';
|
|
85
|
+
import { Tui, TuiAppendPromptParams, TuiAppendPromptResponse, TuiOpenHelpResponse } from './resources/tui';
|
|
55
86
|
import { type Fetch } from './internal/builtin-types';
|
|
56
87
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
57
88
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
@@ -79,6 +110,8 @@ export interface ClientOptions {
|
|
|
79
110
|
*
|
|
80
111
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
81
112
|
* much longer than this timeout before the promise succeeds or fails.
|
|
113
|
+
*
|
|
114
|
+
* @unit milliseconds
|
|
82
115
|
*/
|
|
83
116
|
timeout?: number | undefined;
|
|
84
117
|
/**
|
|
@@ -188,7 +221,7 @@ export class Opencode {
|
|
|
188
221
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
189
222
|
*/
|
|
190
223
|
withOptions(options: Partial<ClientOptions>): this {
|
|
191
|
-
|
|
224
|
+
const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({
|
|
192
225
|
...this._options,
|
|
193
226
|
baseURL: this.baseURL,
|
|
194
227
|
maxRetries: this.maxRetries,
|
|
@@ -199,6 +232,7 @@ export class Opencode {
|
|
|
199
232
|
fetchOptions: this.fetchOptions,
|
|
200
233
|
...options,
|
|
201
234
|
});
|
|
235
|
+
return client;
|
|
202
236
|
}
|
|
203
237
|
|
|
204
238
|
/**
|
|
@@ -344,7 +378,9 @@ export class Opencode {
|
|
|
344
378
|
|
|
345
379
|
await this.prepareOptions(options);
|
|
346
380
|
|
|
347
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
381
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
382
|
+
retryCount: maxRetries - retriesRemaining,
|
|
383
|
+
});
|
|
348
384
|
|
|
349
385
|
await this.prepareRequest(req, { url, options });
|
|
350
386
|
|
|
@@ -422,7 +458,7 @@ export class Opencode {
|
|
|
422
458
|
} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
423
459
|
|
|
424
460
|
if (!response.ok) {
|
|
425
|
-
const shouldRetry = this.shouldRetry(response);
|
|
461
|
+
const shouldRetry = await this.shouldRetry(response);
|
|
426
462
|
if (retriesRemaining && shouldRetry) {
|
|
427
463
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
428
464
|
|
|
@@ -521,7 +557,7 @@ export class Opencode {
|
|
|
521
557
|
}
|
|
522
558
|
}
|
|
523
559
|
|
|
524
|
-
private shouldRetry(response: Response): boolean {
|
|
560
|
+
private async shouldRetry(response: Response): Promise<boolean> {
|
|
525
561
|
// Note this is not a standard header.
|
|
526
562
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
527
563
|
|
|
@@ -598,10 +634,10 @@ export class Opencode {
|
|
|
598
634
|
return sleepSeconds * jitter * 1000;
|
|
599
635
|
}
|
|
600
636
|
|
|
601
|
-
buildRequest(
|
|
637
|
+
async buildRequest(
|
|
602
638
|
inputOptions: FinalRequestOptions,
|
|
603
639
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
604
|
-
): { req: FinalizedRequestInit; url: string; timeout: number } {
|
|
640
|
+
): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> {
|
|
605
641
|
const options = { ...inputOptions };
|
|
606
642
|
const { method, path, query, defaultBaseURL } = options;
|
|
607
643
|
|
|
@@ -609,7 +645,7 @@ export class Opencode {
|
|
|
609
645
|
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
610
646
|
options.timeout = options.timeout ?? this.timeout;
|
|
611
647
|
const { bodyHeaders, body } = this.buildBody({ options });
|
|
612
|
-
const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
648
|
+
const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
613
649
|
|
|
614
650
|
const req: FinalizedRequestInit = {
|
|
615
651
|
method,
|
|
@@ -625,7 +661,7 @@ export class Opencode {
|
|
|
625
661
|
return { req, url, timeout: options.timeout };
|
|
626
662
|
}
|
|
627
663
|
|
|
628
|
-
private buildHeaders({
|
|
664
|
+
private async buildHeaders({
|
|
629
665
|
options,
|
|
630
666
|
method,
|
|
631
667
|
bodyHeaders,
|
|
@@ -635,7 +671,7 @@ export class Opencode {
|
|
|
635
671
|
method: HTTPMethod;
|
|
636
672
|
bodyHeaders: HeadersLike;
|
|
637
673
|
retryCount: number;
|
|
638
|
-
}): Headers {
|
|
674
|
+
}): Promise<Headers> {
|
|
639
675
|
let idempotencyHeaders: HeadersLike = {};
|
|
640
676
|
if (this.idempotencyHeader && method !== 'get') {
|
|
641
677
|
if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
|
|
@@ -718,110 +754,109 @@ export class Opencode {
|
|
|
718
754
|
static toFile = Uploads.toFile;
|
|
719
755
|
|
|
720
756
|
event: API.Event = new API.Event(this);
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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);
|
|
757
|
+
app: API.AppResource = new API.AppResource(this);
|
|
758
|
+
find: API.Find = new API.Find(this);
|
|
759
|
+
file: API.FileResource = new API.FileResource(this);
|
|
760
|
+
config: API.ConfigResource = new API.ConfigResource(this);
|
|
761
|
+
session: API.SessionResource = new API.SessionResource(this);
|
|
762
|
+
tui: API.Tui = new API.Tui(this);
|
|
737
763
|
}
|
|
738
764
|
Opencode.Event = Event;
|
|
739
|
-
Opencode.
|
|
740
|
-
Opencode.
|
|
741
|
-
Opencode.
|
|
742
|
-
Opencode.
|
|
743
|
-
Opencode.
|
|
744
|
-
Opencode.
|
|
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;
|
|
765
|
+
Opencode.AppResource = AppResource;
|
|
766
|
+
Opencode.Find = Find;
|
|
767
|
+
Opencode.FileResource = FileResource;
|
|
768
|
+
Opencode.ConfigResource = ConfigResource;
|
|
769
|
+
Opencode.SessionResource = SessionResource;
|
|
770
|
+
Opencode.Tui = Tui;
|
|
755
771
|
export declare namespace Opencode {
|
|
756
772
|
export type RequestOptions = Opts.RequestOptions;
|
|
757
773
|
|
|
758
774
|
export { Event as Event, type EventListResponse as EventListResponse };
|
|
759
775
|
|
|
760
|
-
export { AppInfo as AppInfo, type AppInfoCreateResponse as AppInfoCreateResponse };
|
|
761
|
-
|
|
762
|
-
export { ConfigGet as ConfigGet, type ConfigGetRetrieveResponse as ConfigGetRetrieveResponse };
|
|
763
|
-
|
|
764
776
|
export {
|
|
765
|
-
|
|
766
|
-
type
|
|
777
|
+
AppResource as AppResource,
|
|
778
|
+
type App as App,
|
|
779
|
+
type Mode as Mode,
|
|
780
|
+
type Model as Model,
|
|
781
|
+
type Provider as Provider,
|
|
782
|
+
type AppInitResponse as AppInitResponse,
|
|
783
|
+
type AppLogResponse as AppLogResponse,
|
|
784
|
+
type AppModesResponse as AppModesResponse,
|
|
785
|
+
type AppProvidersResponse as AppProvidersResponse,
|
|
786
|
+
type AppLogParams as AppLogParams,
|
|
767
787
|
};
|
|
768
788
|
|
|
769
789
|
export {
|
|
770
|
-
|
|
771
|
-
type
|
|
772
|
-
type
|
|
790
|
+
Find as Find,
|
|
791
|
+
type Symbol as Symbol,
|
|
792
|
+
type FindFilesResponse as FindFilesResponse,
|
|
793
|
+
type FindSymbolsResponse as FindSymbolsResponse,
|
|
794
|
+
type FindTextResponse as FindTextResponse,
|
|
795
|
+
type FindFilesParams as FindFilesParams,
|
|
796
|
+
type FindSymbolsParams as FindSymbolsParams,
|
|
797
|
+
type FindTextParams as FindTextParams,
|
|
773
798
|
};
|
|
774
799
|
|
|
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
800
|
export {
|
|
782
|
-
|
|
783
|
-
type
|
|
801
|
+
FileResource as FileResource,
|
|
802
|
+
type File as File,
|
|
803
|
+
type FileReadResponse as FileReadResponse,
|
|
804
|
+
type FileStatusResponse as FileStatusResponse,
|
|
805
|
+
type FileReadParams as FileReadParams,
|
|
784
806
|
};
|
|
785
807
|
|
|
786
808
|
export {
|
|
787
|
-
|
|
788
|
-
type
|
|
789
|
-
type
|
|
809
|
+
ConfigResource as ConfigResource,
|
|
810
|
+
type Config as Config,
|
|
811
|
+
type KeybindsConfig as KeybindsConfig,
|
|
812
|
+
type McpLocalConfig as McpLocalConfig,
|
|
813
|
+
type McpRemoteConfig as McpRemoteConfig,
|
|
814
|
+
type ModeConfig as ModeConfig,
|
|
790
815
|
};
|
|
791
816
|
|
|
792
|
-
export { SessionList as SessionList, type SessionListCreateResponse as SessionListCreateResponse };
|
|
793
|
-
|
|
794
817
|
export {
|
|
795
|
-
|
|
796
|
-
type
|
|
797
|
-
type
|
|
818
|
+
SessionResource as SessionResource,
|
|
819
|
+
type AssistantMessage as AssistantMessage,
|
|
820
|
+
type FilePart as FilePart,
|
|
821
|
+
type FilePartInput as FilePartInput,
|
|
822
|
+
type FilePartSource as FilePartSource,
|
|
823
|
+
type FilePartSourceText as FilePartSourceText,
|
|
824
|
+
type FileSource as FileSource,
|
|
825
|
+
type Message as Message,
|
|
826
|
+
type Part as Part,
|
|
827
|
+
type Session as Session,
|
|
828
|
+
type SnapshotPart as SnapshotPart,
|
|
829
|
+
type StepFinishPart as StepFinishPart,
|
|
830
|
+
type StepStartPart as StepStartPart,
|
|
831
|
+
type SymbolSource as SymbolSource,
|
|
832
|
+
type TextPart as TextPart,
|
|
833
|
+
type TextPartInput as TextPartInput,
|
|
834
|
+
type ToolPart as ToolPart,
|
|
835
|
+
type ToolStateCompleted as ToolStateCompleted,
|
|
836
|
+
type ToolStateError as ToolStateError,
|
|
837
|
+
type ToolStatePending as ToolStatePending,
|
|
838
|
+
type ToolStateRunning as ToolStateRunning,
|
|
839
|
+
type UserMessage as UserMessage,
|
|
840
|
+
type SessionListResponse as SessionListResponse,
|
|
841
|
+
type SessionDeleteResponse as SessionDeleteResponse,
|
|
842
|
+
type SessionAbortResponse as SessionAbortResponse,
|
|
843
|
+
type SessionInitResponse as SessionInitResponse,
|
|
844
|
+
type SessionMessagesResponse as SessionMessagesResponse,
|
|
845
|
+
type SessionSummarizeResponse as SessionSummarizeResponse,
|
|
846
|
+
type SessionChatParams as SessionChatParams,
|
|
847
|
+
type SessionInitParams as SessionInitParams,
|
|
848
|
+
type SessionRevertParams as SessionRevertParams,
|
|
849
|
+
type SessionSummarizeParams as SessionSummarizeParams,
|
|
798
850
|
};
|
|
799
851
|
|
|
800
852
|
export {
|
|
801
|
-
|
|
802
|
-
type
|
|
803
|
-
type
|
|
853
|
+
Tui as Tui,
|
|
854
|
+
type TuiAppendPromptResponse as TuiAppendPromptResponse,
|
|
855
|
+
type TuiOpenHelpResponse as TuiOpenHelpResponse,
|
|
856
|
+
type TuiAppendPromptParams as TuiAppendPromptParams,
|
|
804
857
|
};
|
|
805
858
|
|
|
806
|
-
export
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
type MessagePart as MessagePart,
|
|
810
|
-
type ProviderAuthError as ProviderAuthError,
|
|
811
|
-
type UnknownError as UnknownError,
|
|
812
|
-
type SessionChatCreateParams as SessionChatCreateParams,
|
|
813
|
-
};
|
|
814
|
-
|
|
815
|
-
export { ProviderList as ProviderList, type ProviderListCreateResponse as ProviderListCreateResponse };
|
|
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
|
-
};
|
|
859
|
+
export type MessageAbortedError = API.MessageAbortedError;
|
|
860
|
+
export type ProviderAuthError = API.ProviderAuthError;
|
|
861
|
+
export type UnknownError = API.UnknownError;
|
|
827
862
|
}
|